#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

What is the sizeof () a pointer?

543


What is the Purpose of 'extern' keyword in a function declaration?

649


What is the function of this pointer?

668


Explain union.

633


Why c is called procedure oriented language?

575






Explain how do you generate random numbers in c?

618


the portion of a computer program within which the definition of the variable remains unchanged a) mode b) module c) scope d) none

639


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

1426


Explain what is a 'locale'?

581


Write a program to print "hello world" without using a semicolon?

591


Can a program have two main functions?

565


How can I use a preprocessorif expression to ?

597


What is s or c?

590


Explain what are preprocessor directives?

623


What is the c language function prototype?

642