GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Interview Questions  >  Programming  >  C

 Print  |  
Question:  main()
{
int i, j, *p;
i = 25;
j = 100;
p = &i; // Address of i is assigned to pointer p
printf("%f", i/(*p) ); // i is divided by pointer p
}


Answer: A) Compile error
B) 1.00000
C) Runtime error.
D) 0.00000
Explanation: Error because i/(*p) is 25/25 i.e 1 which is int & printed as a float, so abnormal program termination, runs if (float) i/(*p) -----> Type Casting.


January 01, 2006 03:52:30 #3
 Prasad.... Microsoft Expert  Member Since: January 2006    Total Comments: 6 

RE: main(){ int i, j, *p; i = 25;
 

It will mostly give run time error and not compile time error....

Also use typecasting i.e. use       (float)i/(*p); and you will get 1.0000.. as the answer

     

 

Back To Question