ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   SiteMap shows list of All Categories in this site.
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
how to find that no is int or float?
 Question Submitted By :: Rano
I also faced this Question!!     Rank Answer Posted By  
 
  Re: how to find that no is int or float?
Answer
# 1
Using sizeof() operator.


if(sizeof(no)==2)
 cout<<"no is int";
else 
 cout<<"float";
 
Is This Answer Correct ?    0 Yes 2 No
Srv
 
  Re: how to find that no is int or float?
Answer
# 2
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
Fakkad
 
 
 
  Re: how to find that no is int or float?
Answer
# 3
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 ?    0 Yes 0 No
Rajat Bera
 
  Re: how to find that no is int or float?
Answer
# 4
if(sizeof(no)==2)
  cout<<"Integer";
else if(sizeof(no)==4)
  cout<<"Float";
 
Is This Answer Correct ?    2 Yes 0 No
Prabhat
 
  Re: how to find that no is int or float?
Answer
# 5
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 ?    0 Yes 0 No
Vignesh1988i
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
what are the languages used in c#? Infosys1
what is the use of pointers  5
what is dangling pointer? LG-Soft1
Write a program to find the smallest and largest element in a given array in c language Microsoft3
how to find a 5th bit is set in c program IBM3
Write a program to give following output..... ********* **** **** *** *** ** ** * * ** ** *** *** **** **** *********  2
Is it possible to run a c program without using main?If yes HOW?? Wipro10
What is macro? IBM4
who will call your main function in c under linux?  2
swap two integer variables without using a third temporary variable?  2
In the following control structure which is faster? 1.Switch 2.If-else and which consumes more memory?  4
What is a symbolic constant?  1
2.main { int x,j,k; j=k=6;x=2; x=j*k; printf("%d", x); HCL6
DIFFERNCE BETWEEN THE C++ AND C LANGUAGE? Wipro2
How the C program can be compiled? HP7
print the following using nested for loop. 5 4 3 2 1 1 2 3 4 3 2 1 1 2 1 2 1 1 2 3 4 3 2 1 1 2 3 4 5  5
different between overloading and overriding  3
How to implement call back functions ? HP2
can anyone proide me reading material on svit00ef27@yahoo.com please thanx in advance IBM1
what is y value of the code if input x=10 y=5; if (x==10) else if(x==9) elae y=8; a.9 b.8 c.6 d.7 TCS2
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com