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...

#define MAX(x,y) (x) > (y) ? (x) : (y)
main()
{
int i = 10, j = 5, k = 0;
k = MAX(i++, ++j);
printf("%d %d %d", i,j,k);
}

what will the values of i , j and k?
}

Answer Posted / vidyullatha

In Linux:
O/P: 12 6 11

Explanation:
when k = MAX(i++,++j) is called the macro is replaced and
evaluated as, (i++) > (++j) i.e 11 > 6. As the result of
the statement is true, it executes the statement ? (X) i.e
(i++) on total the statement looks like this
(i++) > (++j) ? (i++)
i.e 11 > 6 ? (i++)
i.e k = i++;
Here as i is post increment first value of i is assigned to
k and then it is incremented.
Hence k = 11.
as i is incremented twice it value is 12
and j is incremented once hence 6
So final O/P is 12 6 11.

Hope this helps.

Is This Answer Correct ?    35 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is #define in c?

1004


the constant value in the case label is followed by a a) semicolon b) colon c) braces d) none of the above

1218


What should malloc() do? Return a null pointer or a pointer to 0 bytes?

1033


Is printf a keyword?

1167


Explain what are its uses in c programming?

1036


What are the advantages of Macro over function?

1957


explain what is an endless loop?

1052


How do you declare a variable that will hold string values?

1130


what is a NULL Pointer? Whether it is same as an uninitialized pointer?

1233


What is infinite loop?

1051


which of the following is not a character constant a) 'thank you' b) 'enter values of p, n ,r' c) '23.56E-o3' d) all of the above

2021


What the different types of arrays in c?

1033


Explain 'far' and 'near' pointers in c.

1103


How many levels of indirection in pointers can you have in a single declaration?

1048


How can I find out the size of a file, prior to reading it in?

1128