how to find that no is int or float?

Answer Posted / rajat bera

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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how to construct a simulator keeping the logical boolean gates in c

1730


What is static and volatile in c?

781


What is an expression?

658


Is there anything like an ifdef for typedefs?

704


Are there namespaces in c?

570






What are the advantages of union?

628


Why does not c have an exponentiation operator?

629


Why structure is used in c?

596


What are the differences between Structures and Arrays?

612


What is variable initialization and why is it important?

621


Explain how can I convert a string to a number?

643


What is structure data type in c?

573


what are the advanced features of functions a) function declaration and prototypes b) calling functions by value or by reference c) recursion d) all the above

679


What is an auto variable in c?

758


Write a program to generate random numbers in c?

664