Int a=0; while(a) {printf("Hii");} What will be the output?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Int a=0; while(a) {printf("Hii");} What will be the output??

Written in C

3rd Dec 2021, 11:45 AM
Ashutosh Modgil
Ashutosh Modgil - avatar
9 Answers
+ 3
Ashutosh Modgil , the code gives no output. In this way as follows you can test and play with a code examples. Please change the variable to a = 1 and see what happend after that. https://code.sololearn.com/ch61OXcU93bd/?ref=app
3rd Dec 2021, 1:22 PM
JaScript
JaScript - avatar
+ 10
Ashutosh Modgil , ▪︎why do you don't try to run the code by yourself? ▪︎you mentioned that the code is written in c. so what is the reason that some other languages are named in the tags?
3rd Dec 2021, 11:51 AM
Lothar
Lothar - avatar
+ 3
Don't rely on the compiler to tell you what's wrong. Try to understand the code. If you do the c basics, you'll understand what the problem is.
3rd Dec 2021, 12:37 PM
Lisa
Lisa - avatar
+ 1
Sir, actually compiler only pop out errors....it doesnt tell us whats the reason behind that its not executing...am just getting the answers from proffesionals out here on sololearn 😊 Hope you will understand me, thanks
3rd Dec 2021, 11:58 AM
Ashutosh Modgil
Ashutosh Modgil - avatar
+ 1
No output
3rd Dec 2021, 6:18 PM
Pranav Hirani
Pranav Hirani - avatar
+ 1
Scoozak as the condition of loop is false the loop I'll never be executed so it's not the case of exaggeration of loop
3rd Dec 2021, 6:21 PM
Pranav Hirani
Pranav Hirani - avatar
+ 1
The output will be a syntax error. There is no type "Int". You surely meant "int". But I can bet the compiler would state this upfront. I didn't understand why you didn't inform the compiler errors.
5th Dec 2021, 1:21 AM
Emerson Prado
Emerson Prado - avatar
0
Well there is two scenarios going to happen. Your program will be not executed since it is endless loop or in other scenario your computer will freeze trying to print it as much as it can.
3rd Dec 2021, 11:47 AM
cadbrooke
cadbrooke - avatar
0
Be careful with the use of the while loop. You must always guarantee the entry of the loop: int a = 10 and not a = 0; Then you have to guarantee the exit of the loop. while ((a--)> 0) // guarantee the output to a = 0 Finally do loop processing.
4th Dec 2021, 12:32 PM
Mahatma Tefnakht
Mahatma Tefnakht - avatar