GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Placement Papers  >  Sonata  >  C
Go To First  |  Previous Question  |  Next Question 
 C  |  Question 27 of 31    Print  
What would be the output of the following program?
main()
{
const int x=5;
int *ptrx;
ptrx=&x;
*ptrx=10;
printf("%d",x);
}
a) 5 b) 10 c) Error d) Garbage value


  
Total Answers and Comments: 4 Last Update: November 11, 2006   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
October 23, 2005 18:09:09   #1  
shrutimitra Member Since: October 2005   Contribution: 16    

RE: What would be the output of the following program...
5. Because the value of x can not be modified .
 
Is this answer useful? Yes | No
December 05, 2005 03:59:14   #2  
Rage Member Since: November 2005   Contribution: 2    

RE: What would be the output of the following program...
The Answer is C. ERROR!First of all you cant store the address(&x) of a const int in a normal integer pointer(*ptrx)we need to declare the pointer(ptrx) as const int *ptrx ; . Well even after this you cant change the value of *ptrx since its a const pointer. Therefore it results in a ERRORThe error before modification wud be cannot conver ' const int * ' to ' int * '
 
Is this answer useful? Yes | No
May 25, 2006 11:44:07   #3  
Krupa        

RE: What would be the output of the following program...
option b is the answer
 
Is this answer useful? Yes | No
November 11, 2006 08:21:59   #4  
manoj        

RE: What would be the output of the following program...
the answer is 10 .please dont put wrong answers and guess so that others may not be misguided.
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape