0
#include <stdio.h> int main() { do{ printf("Hi"); }while(5,3,0); return 0; }
Why Hi is printed only once and Not Three times?? https://code.sololearn.com/cavzumMug000/?ref=app
7 ответов
+ 3
Because 5,3,0 makes no sense and therefore compiler gives an error . The only reason it ran was due to do statement.
Following code will print 3 times,
int i=3;
do{
printf("Hi");
}while(--i);
return 0;
}
+ 4
Here's info about comma operator. May it helps you understand why the code is acting as it does.
https://sillycodes.com/comma-operator-in-c-programming/
+ 2
#include <stdio.h>
int main() {
int i =0;
do{
printf("Hi\n");
i++;
}while(i<3);
return 0;
}
+ 2
Sanjeeb Kumar Rai
Sorry bro, yes that one is not working. I have put another link that may help you understand this comma operator there ☝
+ 1
Thanks a lot
+ 1
Ipang The link seems to be broken
+ 1
Ipang Thanks bro