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 need of structure in c?

558


How does selection sort work in c?

611


What is data types?

628


Can you explain what keyboard debouncing is, and where and why we us it? please give some examples

1646


What is the -> in c?

573






a single linked list consists of nodes a to z .print the nodes in reverse order from z to a using recursion

2328


Is javascript based on c?

588


What are linker error?

606


Explain what are compound statements?

597


What is the acronym for ansi?

622


What is the difference between malloc() and calloc()?

609


What is the purpose of the statement: strcat (S2, S1)?

636


How can you avoid including a header more than once?

553


general for is %wd,f-d; in this system "w" means a) 'w' represent total width of digits b) 'w' represent width which includes the digits before,after decimal place and the decimal point c) 'w' represent width which includes the digits before only d) 'w' represent width after decimal place only

580


what do you mean by inline function in C?

605