Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


main()
{
int x=20,y=35;
x = y++ + x++;
y = ++y + ++x;
printf("%d %d\n",x,y);
}

Answers were Sorted based on User's Feedback



main() { int x=20,y=35; x = y++ + x++; y = ++y + ++x; printf(&q..

Answer / jaya prakash

57 94


{x=y++ + x++;}
equal to
{
x=y+x;//35+20
x++; //56
y++; //36
}


y=++y + ++x;
equal to
{
++y;//37
++x;//57
y=y+x;//37+57
}

So x=57
y=94

Is This Answer Correct ?    223 Yes 59 No

main() { int x=20,y=35; x = y++ + x++; y = ++y + ++x; printf(&q..

Answer / preethi

57
94

Is This Answer Correct ?    106 Yes 34 No

main() { int x=20,y=35; x = y++ + x++; y = ++y + ++x; printf(&q..

Answer / bala

56 93.

I will rewrite the above program for ur understand.

int x=20,y=35;
int x1,y1;
x1=y++ + x++; //this line y=35 and x=20 before assign the
value to x.
x=x1; // Value of x1=55, y=36 and x=21.
y1=++y + ++x;//this line y=37 and x=56 before assign the
value to y.
y=y1;// Value of x=56, y=37 and y1=93.
Finally x=56 and y=93

Is This Answer Correct ?    56 Yes 10 No

main() { int x=20,y=35; x = y++ + x++; y = ++y + ++x; printf(&q..

Answer / manju

while calculating the x value,x & y values are post
incremented.So the values of x & y are added and then
incremented i.e. x=56,y=36
while calculating the y value,x & y values are
preincremtned,so x & y values are incremented and then
added i.e. x=57,y=37.
so x=57
y=57+37=94.

Is This Answer Correct ?    58 Yes 18 No

main() { int x=20,y=35; x = y++ + x++; y = ++y + ++x; printf(&q..

Answer / joseph

Here this should make it easier for you...

Problem_________|___Solution__|

int x=20, y=35; (here the values of x,y are apparent.)

x = y++ + x++; (x=y+x+1) or(x = 35 + 20 + 1)x = 56
But; you incremented y, its now = 36

y = ++y + ++x; (y =(y+1)+(x+1)) or(y=1+36+1+56)y = 94
This is the second time you incremented
x so it is now = 57.


The reason that you are getting different increases
for x and y is that when you use statement(x=x++) you are
first stating that x is = to x, and then 'increment x.
when you use statemnt(x=++x) you are first
stating 'increment x, then that x is = to x.

look at the code and description in the chart below.

table:
code = meaning;
int x=2
int y=2
-------------------|
(x=x++) = "x = x, x + 1" (increment happens after)
(x=++x) = "x = (x+1)" (increment happens before)
(x=y++) = "x = y, y + 1" (increment happens after)
(x=++y) = "x = (y+1)" (increment happens before)

if you want to add y to x and then increment y use this
statement:

x+=y++

if you want to increment y and then add it to x use this
statement:

x+=++y

Is This Answer Correct ?    25 Yes 7 No

main() { int x=20,y=35; x = y++ + x++; y = ++y + ++x; printf(&q..

Answer / valli

x=57
y=94

Is This Answer Correct ?    29 Yes 16 No

main() { int x=20,y=35; x = y++ + x++; y = ++y + ++x; printf(&q..

Answer / rohit

57 94

Is This Answer Correct ?    33 Yes 21 No

main() { int x=20,y=35; x = y++ + x++; y = ++y + ++x; printf(&q..

Answer / chandrasekhar

56 93

Is This Answer Correct ?    8 Yes 4 No

main() { int x=20,y=35; x = y++ + x++; y = ++y + ++x; printf(&q..

Answer / lucky

correct answer is 57 94

Is This Answer Correct ?    16 Yes 13 No

main() { int x=20,y=35; x = y++ + x++; y = ++y + ++x; printf(&q..

Answer / ledia

The program results in an undefined behaviour. You're wrong
if you have a certain answer. Learn more on the wikipedia
http://en.wikipedia.org/wiki/Sequence_point

Is This Answer Correct ?    5 Yes 4 No

Post New Answer

More C Interview Questions

please explain clearly about execution of c program in detail,in which stage are the printf sacnf getting into exeecutable code

0 Answers   Mind Tree,


What is malloc return c?

0 Answers  


struct abc { unsigned int a; char b; float r; }; struct xyz { int u; struct abc tt; }ww; ww = (struct xyz*)malloc(sizeof(struct xyz)); will the memory be allocated for the inner structure also?

1 Answers   Wipro,


what is the difference between 123 and 0123 in c?

0 Answers  


What is string function in c?

0 Answers  


what is the output of the following program? #include<stdio.h> void main() { int x=4,y=3,z; z=x-- -y; printf("\n%d %d %d",x,y,z); }

14 Answers  


program to convert a integer to string in c language'

0 Answers  


What is struct node in c?

0 Answers  


How can I call a function with an argument list built up at run time?

0 Answers  


What is modifier & how many types of modifiers available in c?

0 Answers  


Explain what is the difference between a string and an array?

0 Answers  


how to find string length wihtout using c function?

6 Answers  


Categories