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
Go To First  |  Previous Question  |  Next Question 
 C  |  Question 140 of 436    Print  
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
}
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.



  
Total Answers and Comments: 9 Last Update: August 12, 2008   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
December 15, 2005 05:05:23   #1  
NAVNISH JAIN        

RE: main(){ int i, j, *p; i = 25;
it is compiler dependent.
 
Is this answer useful? Yes | No
December 15, 2005 05:08:13   #2  
NAVNISH JAIN        

RE: main(){ int i, j, *p; i = 25;
it is compiler dependent.
 
Is this answer useful? Yes | No
January 18, 2006 03:52:30   #3  
C_learner Member Since: January 2006   Contribution: 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


 
Is this answer useful? Yes | No
May 15, 2006 18:46:35   #4  
sravanan        

RE: main(){ int i, j, *p; i = 25;
compiler error.because division is not possible usinsg pointers.
 
Is this answer useful? Yes | No
May 16, 2006 02:56:15   #5  
shweta        

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

hi,

this gives runtime error.

i tried to run program in vc with .c extension file.

it  gives runtime error


 
Is this answer useful? Yes | No
March 03, 2007 00:02:36   #6  
noname2000 Member Since: February 2007   Contribution: 1    

RE: main(){ int i, j, *p; i = 25;
i try compile with turbo C++ and it print out a garbage value. No error.
 
Is this answer useful? Yes | No
January 13, 2008 04:59:48   #7  
Kalpitgdeewan Member Since: December 2007   Contribution: 1    

RE: 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}
it gives 0.00000 as the output when we run it :P
 
Is this answer useful? Yes | No
January 16, 2008 05:37:24   #8  
santhigkinterview Member Since: January 2008   Contribution: 5    

RE: 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}

Run time Error – Floating point not loaded.

printf("%f", i/(*p) ); // i is divided by pointer p

 

by doing type casting (float)i/(*p) we can avoid this error.


 
Is this answer useful? Yes | No
August 12, 2008 11:45:42   #9  
sourabh_t Member Since: August 2008   Contribution: 2    

RE: 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}
C. Runtime Error
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape