Why this code output "No output" while inputting non zero numbers? In c | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why this code output "No output" while inputting non zero numbers? In c

While inputting zero,it works fine and I get the expected output..... https://code.sololearn.com/c1Zy9KutAh3Y/?ref=app

16th Feb 2021, 12:02 PM
Yogeshwaran P
Yogeshwaran P - avatar
2 Answers
+ 4
Because as soon as you input any other number than zero, the for loop becomes an infinite loop. as apart from scanf() the value of "num" is not changed anywhere through the code (especially inside the loop ) making the condition (num != 0) always true when a non zero digit is entered
16th Feb 2021, 12:05 PM
Arsenic
Arsenic - avatar
+ 1
Arsenic thank you very much 😄... After seeing your reply only, I identify my simple mistake on this code 😅 Once again thank you arsenic
16th Feb 2021, 12:15 PM
Yogeshwaran P
Yogeshwaran P - avatar