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

Explain how can a program be made to print the name of a source file where an error occurs?

1253


in programming languages a statement or part of a statement that specifies several different execution sequences a) constructs b) distructs c) executes d) none

1156


what are enumerations in C

1224


What is sizeof return in c?

1095


What is data type long in c?

1119


What is variable and explain rules to declare variable in c?

1181


Explain how do you determine whether to use a stream function or a low-level function?

1138


Explain what is the benefit of using const for declaring constants?

1093


What do you mean by a local block?

1134


What is difference between array and structure in c?

1276


What is the difference between volatile and const volatile?

1053


By using C language input a date into it and if it is right?

1140


What does int main () mean?

1081


Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]

1135


What is %g in c?

1124