main() { int a=10; printf("%d", a++); printf("%d",a); } What is the output?
Answers
Answered by
0
Output for the above program -
10
11
Answered by
0
Output of the given piece of code is:
10
11
- In c language, main() is the function, place from where the execution of the code begins.
- In the first statement inside main(),
int a = 10;
a variable with the name 'a' is declared with the data type of <int> and is simultaneously initialized to the value 10.
- printf() is a library function in c language, which is used to to display formatted output to the console.
- In the second statement inside main(),
printf("%d", a++);
++ is an increment operator and it is behaving as postfix operator in this case.
- Hence in the second statement, first the value of a i.e. 10 is printed to the console and then it incremented by 1, after the execution of this statement.
- In the statement
printf("%d",a);
the value of the variable 'a', which is 11 now, is printed to the console.
- Hence, output of the given piece of code is:
10
11
#SPJ3
Similar questions