Important : Please do NOT wait for job alert emails. Sometimes, we may NOT be able to send emails due to server problems. So always directly visit www.ChetanaSforum.com to view all jobs DAILY, so that you will NOT miss important Walk-In. We suggest you to LIKE OUR FACEBOOK PAGE to keep track of new jobs through Facebook.
Home    Register    Facebook    Post Jobs for Free    Jobs By Location    Exclusive Off-Campus    2013 Batch   Job Fairs    JavaKen.com    TestingKen.com
Infosys, TCS, Yahoo & Amazon are hiring. Register Now ! Submit Resume to 50,000 Recruiters LIKE our FaceBook Page
IPB

Welcome Guest ( Log In | Register )




Tags
This content has not been tagged yet
 
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





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
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 18th May 2013 - 04:32 PM