#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

Why can’t we compare structures?

801


What are the differences between Structures and Arrays?

594


What do mean by network ?

646


Explain how can type-insensitive macros be created?

564


What are types of preprocessor in c?

609






What are the benefits of c language?

637


What's the right way to use errno?

611


Why c is called a middle level language?

627


Explain can the sizeof operator be used to tell the size of an array passed to a function?

582


What is #include stdio h and #include conio h?

586


Explain which function in c can be used to append a string to another string?

572


which is an algorithm for sorting in a growing Lexicographic order

1383


Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?

646


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

1452


Do you know pointer in c?

572