#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
Why can’t we compare structures?
What are the differences between Structures and Arrays?
What do mean by network ?
Explain how can type-insensitive macros be created?
What are types of preprocessor in c?
What are the benefits of c language?
What's the right way to use errno?
Why c is called a middle level language?
Explain can the sizeof operator be used to tell the size of an array passed to a function?
What is #include stdio h and #include conio h?
Explain which function in c can be used to append a string to another string?
which is an algorithm for sorting in a growing Lexicographic order
Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?
WHICH TYPE OF JOBS WE GET BY WRITING GROUPS .WHEN THE EXAMS CONDUCTED IS THIS EXAMS ARE CONDUCTED EVERY YEAR OR NOT.PLS TELL ME THE ANSWER
Do you know pointer in c?