Originally Posted by
Salem
Just run the code in a debugger, step through it line by line if you're confused.
I don't have gdb but I am using printf statement for debugging
Code:
#include <stdio.h>
int main()
{
int x;
x = 10;
if(x > 10){
x -= 10;
printf("True condition 1 x : %d\n", x);
}
else if(x >= 0){
x += 00;
printf("True condition2 x : %d \n", x);
}
else if(x){ // x = 10 none zero I don't understand why it doesn't execute
x += 10;
printf("True condition3 x : %d \n", x);
}
else{
x -= 10;
printf("True condition4 x : %d \n", x);
}
printf("final x : %d\n",x);
return 0;
}
True condition2 x : 10
final x : 10
my only question
Code:
else if(x){ // x = 10 none zero I don't understand why it doesn't execute
x += 10;
printf("True condition3 x : %d \n", x);
}