Jump to content


Photo

c predict output







  • Please log in to reply
4 replies to this topic

#1 ankit chitkara






Posted 18 April 2010 - 11:45 AM

- PLEASE SHARE

void main(){int count=10,*temp,sum=0;temp=&count;*temp=20;temp=∑*temp=count;printf("%d %d %d ",count,*temp,sum);}If possible explain also


#2 ankit chitkara

ankit chitkara

    Advanced Member

  • Members
  • PipPipPip
  • 86 posts

Posted 18 April 2010 - 01:12 PM

any one who can answer?

#3 kannan devarajan

kannan devarajan

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 18 April 2010 - 06:04 PM

void main() { int count=10,*temp,sum=0; temp=&count; *temp=20; temp=∑ *temp=count; printf("%d %d %d ",count,*temp,sum); } If possible explain also

void main() { int count=10, sum=0; int *temp; temp=&count;// here u r assigning address of count to temp. *temp=20;//temp is pointing to count now. *temp means value at temp. the value at temp is count. so count is 20 now. temp=∑//overwriting the content of temp with address of sum *temp=count;//count value is 20 as mentioned earlier. now *temp is pointing to sum. so sum will be assigned as 20. printf("%d %d %d ",count,*temp,sum);//all are 20 here. }

#4 ankit chitkara

ankit chitkara

    Advanced Member

  • Members
  • PipPipPip
  • 86 posts

Posted 18 April 2010 - 06:51 PM

nice answer Keep it up

#5 kuber saini

kuber saini

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 13 March 2012 - 12:32 PM

any one who can answer?

void main() { int count=10, sum=0; int *temp; temp=&count; //Now temp will point the address of count variable. *temp=20; //We are assigning the value to the address which temp is pointing, so the changes will reflect in count variable,bcoz temp pointing to the count variable temp=∑ //Again we are assigning the new address to temp, so now temp will point the address of sum. *temp=count; //value of count variable is 20 & it will assign to sum variable(look at just above line). printf("%d %d %d ",count,*temp,sum); //all will be 20. }




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users