Question
#include<stdio.h>
int func1(int);
int main()
{
int k=35;
k = func1(k=func1(k=func1(k)));
printf("k=%d\n", k);
return 0;
}
int func1(int k)
{
k++;
return k;
}
What will be the output of the program?
#include<stdio.h>
int func1(int);
int main()
{
int k=35;
k = func1(k=func1(k=func1(k)));
printf("k=%d\n", k);
return 0;
}
int func1(int k)
{
k++;
return k;
}
Answer: Option D
Was this answer helpful ?
Step 1: int k=35; The variable k is declared as an integer type and initialized to 35.
Step 2: k = func1(k=func1(k=func1(k))); The func1(k) increement the value of k by 1
and return it. Here the func1(k) is called 3 times. Hence it increements value of k = 35
to 38. The result is stored in the variable k = 38.
Step 3: printf("k=%d`setminus`n", k); It prints the value of variable k "38".
Was this answer helpful ?
Submit Solution