#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

How do I send escape sequences to control a terminal or other device?

804


What is static and volatile in c?

962


How can you call a function, given its name as a string?

891


What is the right type to use for boolean values in c?

779


What is data structure in c language?

815






what is the differnce between programing langauge and tool? is sas is a programing langauge r tool?

2084


What is string constants?

868


Explain the use of 'auto' keyword in c programming?

877


How would you use the functions fseek(), freed(), fwrite() and ftell()?

891


What is a dynamic array in c?

783


how to write optimum code to divide a 50 digit number with a 25 digit number??

2961


What is struct node in c?

790


What is the benefit of using const for declaring constants?

776


What is getche() function?

797


what type of questions arrive in interview over c programming?

1755