What is the output of the following C program?
#include<stdio.h> int main() { int a, b = 10; a = -b--; printf("a = %d, b = %d", a, b); return 0; }
Studently Answered question October 10, 2022
Output:
a = -10, b = 9
The statement ‘a = -b-;’ compiles successfully. Unary minus and unary decrement have right to left associativity and save precedence. As a result, ‘-b-‘ is treated as -(b-), which is correct. As a result, ‘a’ will be assigned a -10, and ‘b’ will be assigned a 9.
Studently Answered question October 10, 2022