So in my finals there was an exercise asking what will the program print.
This is the code:
#include <stdio.h>
int main (){
int x=5, y=4;
if (x>y);
printf("A");
if(x=4)
printf("%d",x+y);
return 0;
}
When I try to compile it using gcc -ansi -pedantic -Werror
on a Debian machine, it compiles just fine and outputs "A8".
However, when I try to compile it using clang -ansi -pedantic -Werror
, I receive errors regarding the if (x=4)
expression missing =
and missing statement on if(x>y);
.
Why does that happen, and which answer could be marked as correct?