- 1
What is the output of this code? #include <stdio.h> int main() { do { printf("Hi"); } while(5,3,0); return 0; }
Please explain the logic how the output is 'Hi'
1 Answer
+ 3
The comma operator evaluates both of its arguments in turn, throwing away the result, except for the last. The last evaluated expression determines the result of the entire expression.
https://stackoverflow.com/questions/41611557/c-programming-comma-operator-within-while-loop
So it's like you have just while( 0 );
The do{} prints "Hi" and the while never repeats.