+ 1

Why is the output of this code vary to compiler? 😐

#include<stdio.h> main() { int a=5; printf("%d %d %d", ++a, a,a++) ; }

11th Oct 2020, 6:55 AM
Gulpam Doyel
Gulpam Doyel - avatar
8 ответов
+ 2
Since u are returning 0, your header should be int main() and not simply main()
11th Oct 2020, 7:04 AM
Alphin K Sajan
Alphin K Sajan - avatar
+ 1
Modern compilers may complain about main function return type being undefined or be set to void. About the why ... https://stackoverflow.com/questions/4176328/undefined-behavior-and-sequence-points
11th Oct 2020, 7:41 AM
Ipang
+ 1
What are the outputs you get? And what compilers r being used?
11th Oct 2020, 8:03 AM
arturop200
arturop200 - avatar
+ 1
Are you sure this code output varies with compiler.? I think it's not
11th Oct 2020, 8:22 AM
Azhagesanヾ(✿)
Azhagesanヾ(✿) - avatar
+ 1
Azhagesan yeah.. i checked.. other versions of codeblocks show different output..
11th Oct 2020, 8:43 AM
Gulpam Doyel
Gulpam Doyel - avatar
0
I think it should be by default integer.. (edited).. then the real ans plz. ❤
11th Oct 2020, 7:08 AM
Gulpam Doyel
Gulpam Doyel - avatar
0
775 in codeblocks IDE(version 17.12) GNU GCC compiler
11th Oct 2020, 8:05 AM
Gulpam Doyel
Gulpam Doyel - avatar
0
Mohammad Hasan but thats just only one you have used
11th Oct 2020, 8:14 AM
arturop200
arturop200 - avatar