+ 7
#include<stdio.h> int main(){ int i=2,j=2; while(i+1?âi:j++) printf(â%dâ,i); return 0; }
what will be the output?
10 Answers
+ 10
while loop is wrong. check the C++ course and change it.
+ 8
just change one thing you'll get an answer..
+ 7
if anyone of you interested, just solve this code.. print the output as 1..
+ 7
I know it is.. but someone have knowledge about this.. if you are the person who someone.. you can solve this..
+ 6
Output:Â 1
Consider the while loop condition: i + 1 ? â i : ++j
In first iteration:
i + 1 = 3 (True)
So ternary operator will return -âi i.e. 1
In c 1 means true so while condition is true. Hence printf statement will print 1
In second iteration:
i+ 1 = 2 (True)
So ternary operator will return -âi i.e. 0
In c zero means false so while condition is false. Hence program control will come out of the while loop.
+ 6
The while loop will always be true umm..
+ 5
Output will be 22222... and it is infinite loop.....
since the while condition is conditional operator it performs the logic without terminating .
The print statement is i, where i is 2...it doesnt changes since we didn't assign it ...Is this correct I also executed
+ 4
WHAT have u created an error mess
+ 4
And so it will go in infinite loop and will print 2 infinitely
0
Idk