I expect that this program prints "hello" one time but it produces error .explain why | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I expect that this program prints "hello" one time but it produces error .explain why

#include <stdio.h> int main() { int k=1; for(k) printf ("hello"); return 0; }

26th Feb 2019, 4:34 PM
Shaik Abeedh
Shaik Abeedh - avatar
1 Answer
+ 1
Because that's not how for loops work. You can change it like this to create an infinite loop: for(;k;)
26th Feb 2019, 5:42 PM
Anna
Anna - avatar