#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 does the c in ctime mean?
What is array of pointers to string?
What is header file in c?
What is LINKED LIST? How can you access the last element in a linked list?
What is variable initialization and why is it important?
write a programming in c to find the sum of all elements in an array through function.
What are two dimensional arrays alternatively called as?
What is a void pointer? When is a void pointer used?
What's a good way to check for "close enough" floating-point equality?
Which are low level languages?
What is the condition that is applied with ?: Operator?
Explain 'bit masking'?
What is pivot in c?
Explain how can I prevent another program from modifying part of a file that I am modifying?
c program for searching a student details among 10 student details