#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
Explain how can a program be made to print the name of a source file where an error occurs?
in programming languages a statement or part of a statement that specifies several different execution sequences a) constructs b) distructs c) executes d) none
what are enumerations in C
What is sizeof return in c?
What is data type long in c?
What is variable and explain rules to declare variable in c?
Explain how do you determine whether to use a stream function or a low-level function?
Explain what is the benefit of using const for declaring constants?
What do you mean by a local block?
What is difference between array and structure in c?
What is the difference between volatile and const volatile?
By using C language input a date into it and if it is right?
What does int main () mean?
Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]
What is %g in c?