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 |
Write a program to display all the prime nos from 1 to 1000000, your code should not take time more than a minute to display all the nos.
What is RAM memory? and What is ROM?Who designed one is temparary and another is permanent?why they designed like that?By using far pointer which type data(whether hexadecimal)we can access?
Write a program to find the number of times that a given word(i.e. a short string) occurs in a sentence (i.e. a long string!). Read data from standard input. The first line is a single word, which is followed by general text on the second line. Read both up to a newline character, and insert a terminating null before processing. Typical output should be: The word is "the". The sentence is "the cat sat on the mat". The word occurs 2 times.
please give me some tips for the selection in TCS.
what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?
the maximum value that an integer constant can have is a) -32767 b) 32767 c) 1.701e+38 d) -1.7014e+38
What is unsigned int in c?
How can you increase the size of a statically allocated array?
What is conio h in c?
Tell me what is the purpose of 'register' keyword in c language?
What is difference between static and global variable in c?
What does %p mean?