Important : Please do NOT wait for job alert emails. Always directly visit www.ChetanaSforum.com to check all jobs DAILY.
Important : We suggest you to SUBSCRIBE HERE to keep track of new jobs through Email. You will get only 1 Email per day.

Home | Register | Facebook | Subscribe Job Alerts | Check Recent Jobs | Post Jobs for Free | RSS | JavaKen.com | TestingKen.com

Infosys, TCS, Yahoo & Amazon are hiring. Register Now ! Submit Resume to 45,000 Recruiters Apply for 52,000 jobs in India
IPB

Welcome Guest ( Log In | Register )




 
Reply to this topicStart new topic
> c predict output, Tcs Interview question
ankit chitkara
post Apr 18 2010, 11:45 AM
Post #1


Advanced Member
***

Group: Members
Posts: 86
Joined: 6-November 09
Member No.: 247,312





Apply for 52,000+ jobs in India ! Post Your Resume !
Infosys, TCS, Yahoo & Amazon are hiring. Register Now !
If you like this post, please share it to help others.


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

Submit Latest Resume Now !





--------------------
ankit
Go to the top of the page
 
+Quote Post
ankit chitkara
post Apr 18 2010, 01:12 PM
Post #2


Advanced Member
***

Group: Members
Posts: 86
Joined: 6-November 09
Member No.: 247,312




any one who can answer?



--------------------
ankit
Go to the top of the page
 
+Quote Post
kannan devarajan
post Apr 18 2010, 06:04 PM
Post #3


Newbie
*

Group: Members
Posts: 1
Joined: 17-March 10
From: Chennai
Member No.: 292,682




QUOTE (ankit chitkara @ Apr 18 2010, 12:45 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.
}




Go to the top of the page
 
+Quote Post
ankit chitkara
post Apr 18 2010, 06:51 PM
Post #4


Advanced Member
***

Group: Members
Posts: 86
Joined: 6-November 09
Member No.: 247,312




nice answer

Keep it up



--------------------
ankit
Go to the top of the page
 
+Quote Post
kuber saini
post Mar 13 2012, 12:32 PM
Post #5


Newbie
*

Group: Members
Posts: 1
Joined: 13-June 10
Member No.: 340,235




QUOTE (ankit chitkara @ Apr 18 2010, 01:12 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.
}

Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

 



RSS Lo-Fi Version Time is now: 20th June 2013 - 11:27 AM