how to find that no is int or float?
Answers were Sorted based on User's Feedback
Answer / prabhat
if(sizeof(no)==2)
cout<<"Integer";
else if(sizeof(no)==4)
cout<<"Float";
| Is This Answer Correct ? | 5 Yes | 2 No |
Answer / fakkad
incomplete solution.
why? what if no is "long int" or "double"?
in that case his solution will always print float.
| Is This Answer Correct ? | 2 Yes | 0 No |
bool __inline is_integer(float f){
int i = f;
return (f == static_cast<float>(i));
}
int main()
{
int num=0;
double num2= 1234;
num=num2;
if(is_integer(num2))
printf("the number is int");
else
printf("the number is float");
getch();
return 0;
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / vignesh1988i
one way according to me is to find through the no. of bytes allocated for that variable or the value itself directly...........
thank u
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / srv
Using sizeof() operator.
if(sizeof(no)==2)
cout<<"no is int";
else
cout<<"float";
| Is This Answer Correct ? | 1 Yes | 4 No |
What compilation do?
7 Answers Geometric Software, Infosys,
what is the difference between postfix and prefix unary increment operators?
hi any body pls give me company name interview conduct "c" language only
What is the g value paradox?
What is the use of bitwise operator?
struct screen_pos{ int row, col } ;move_right(cursor)struct screen_pos *cursor;{ cursor.col++; } /* This statementhas a syntax error */What is the correct statement a) cursor.col = cursor.col + 1; b) col.cursor++; c) *cursor.col++; d) pointer
A SIMPLE PROGRAM OF GRAPHICS AND THEIR OUTPUT I WANT SEE WAHAT OUTOUT OF GRAPHICS PROGRAM
Write a c program to build a heap method using Pointer to function and pointer to structure ?
Explain the advantages and disadvantages of macros.
Are there namespaces in c?
coding for Fibonacci.?
main() { int i,n=010; int sum=0; for(i=1;i<=n;i++) {s=s+i; } printf("%d",&s); getch(); }