- 1
Why this code showing no ouptput
#include <stdio.h> int main() { int num = 5; while (num > 0) { if (num == 3) continue; num--; printf("%d\n", num); } } EDIT : SOLVED
13 Respostas
+ 3
The code would print
4
3
and then loop inifinitely.
During run time Sololearn redirects the output to a file. Normally when the program finishes, Sololearn displays the output file. But because your process has to be killed due to exceeding its time limit, the file is forced closed before the cached write occurs. So the output file is empty.
+ 5
if num==3, it is stuck in infinite loop. You may want to put num-- before if num==3 to see the output !!
+ 3
Abhinraj maybe it has something to do with sololearn .
+ 2
It seems your code doesn't want to output anything:) Abhay is right.
while(num>0) if ((num--)!=3) printf("%d\n",num+1)
+ 2
Abhinraj while (num) works; no need of the 'num > 0' part.
+ 1
Calvin Thomas ..yes u r right.thanks
0
Okk...then 'no output' showing because of run time error ?
0
Bro it showing "No Output"
0
Brian Thanks âš.now it is clear
0
Thanks guys âš
0
Yes after printing 4 3 while loop in infinite time .so num-- write before if conditions
0
while (num>0)
num--
if(num==3)
continue;
printf ("%d",num);
Output-4 2 1
0
https://code.sololearn.com/cCyDVKay9sWC
problem solved