#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
What is #define in c?
the constant value in the case label is followed by a a) semicolon b) colon c) braces d) none of the above
What should malloc() do? Return a null pointer or a pointer to 0 bytes?
Is printf a keyword?
Explain what are its uses in c programming?
What are the advantages of Macro over function?
explain what is an endless loop?
How do you declare a variable that will hold string values?
what is a NULL Pointer? Whether it is same as an uninitialized pointer?
What is infinite loop?
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
What the different types of arrays in c?
Explain 'far' and 'near' pointers in c.
How many levels of indirection in pointers can you have in a single declaration?
How can I find out the size of a file, prior to reading it in?