+ 2
Whats wrong with this code?Please help!
//why error #include<stdio.h> #define greater(x,y) if(x>y) \ printf("%d is greater than %d", x,y);\ else \ printf("%d is smaller than %d", x,y); int main() { greater(5,6); return 0; }
2 Antworten
+ 1
I don't see anyway logical or syntactic errors. The output is as expected.
Obviously remember to remove the empty newlines in the "define" body, or put continuation backslashes in them.
And the "else printf" is not strictly correct: x could be also equal to y, not just smaller !
+ 1
Coding Gl
#include<stdio.h>
#define greater(x,y) if(x>y) printf("%d is greater than %d", x,y);\
else printf("%d is smaller than %d", x,y);
int main()
{
greater(5,6);
return 0;
}