(c programming)
Examine the following code:
int x = 5; while(x = 0){ x += x; } while(x-- > 5){}
What is the final value of x? Does the assignment expression in the first loop occur and if so, what value does it evaluate to?
#include <stdio.h> int main() { int x = 5; while(x = 0){ x += x; } while(x-- > 5){} printf("%d",x); return 0; }
-1
the final value of x is -1 the assignment expression in the first loop occur So, the value of x will be 0 and then after executing the expression x-- > 5 the value of x will be -1 So, final value of x is -1
Get Answers For Free
Most questions answered within 1 hours.