#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 the sizeof () a pointer?
What is the Purpose of 'extern' keyword in a function declaration?
What is the function of this pointer?
Explain union.
Why c is called procedure oriented language?
Explain how do you generate random numbers in c?
the portion of a computer program within which the definition of the variable remains unchanged a) mode b) module c) scope d) none
what is the c source code for the below output? 10 10 10 10 10 10 10 10 10 10 9 9 7 6 6 6 6 6 6 9 7 5 9 7 3 2 2 5 9 7 3 1 5 9 7 3 5 9 7 4 4 4 4 5 9 7 8 8 8 8 8 8 8 8 9
Explain what is a 'locale'?
Write a program to print "hello world" without using a semicolon?
Can a program have two main functions?
How can I use a preprocessorif expression to ?
What is s or c?
Explain what are preprocessor directives?
What is the c language function prototype?