in Programming in C
375 views
0 votes
0 votes

What will be the output of the below C program?

#include <stdio.h>
int xyz(int b)
{
	return (b--);
}
           
int main()
{
    int a = xyz(12);
	printf("%d", ++a);
	return 0;
}

(a)10 (b)11 (c)12 (d)13

in Programming in C
by
375 views

1 comment

on function calling... b=12

return b-- ===> return 12 only

in printf statement ++a ====> a=13
0
0

1 Answer

0 votes
0 votes
The output of the given function will be 13.

As the function xyz is using post decrement operator it would return the value 12 when xyz is called for 12. The result has been stored in a and before we are printing a we are using a pre increment operator and the value of a changes to 13 and then the ans is beng printed.

Related questions