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 |
Explain what is the use of a semicolon (;) at the end of every program statement?
The number of bytes of storage occupied by short, int and long are a) 2, 2 and 4 b) 2, 4 and 4 c) 4, 4 and 4 d) none
Differentiate between static and dynamic modeling.
main() { int x, arr[8]={11,22,33,44,55,66,77,88}; x=(arr+2)[3]; printf(ā%dā,x); }
a character or group of characters that defines a register,or a part of storage a) memory b) byte c) address d) linear list
What are the different types of pointers?
What is %s and %d in c?
How can you return multiple values from a function?
in any language the sound structure of that language depends on its a) character set, input/output function, its control structures b) character set, library functions, input/output functions its control structures c) character set, library functions, control sturctures d) character set, operators, its control structures
Why is sizeof () an operator and not a function?
Can anyone help me with this please? Need to print the below values.. Thanks 1 1 2 1 2 3 1 2 3 4
difference between my-strcpy and strcpy ?
3 Answers Geometric Software, IIM, Infosys,