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

What is the right way to use errno?

832


What is c language in simple words?

818


How to throw some light on the b tree?

820


What is the difference between specifying a constant variable like with constant keyword and #define it? i.e what is the difference between CONSTANT FLOAT A=1.25 and #define A 1.25

1716


What is structure packing in c?

823


A character flag or control mechanism that delineates one data item from another a) variable b) constant c) delimiter d) call by reference

859


What are the data types present in c?

852


What are the functions to open and close the file in c language?

811


What are the advantages and disadvantages of a heap?

932


How can I generate floating-point random numbers?

801


I have seen function declarations that look like this

807


What are examples of structures?

803


What is equivalent to ++i+++j?

862


Which of the following operators is incorrect and why? ( >=, <=, <>, ==)

900


Can you define which header file to include at compile time?

801