+ 2
Can anyone tell and explain the output of following code?
#include<stdio.h> int main() { printf("Hi") ; main() ; return 0 ; }
9 ответов
+ 4
Amit kumar This is called recursion of a function. Due to the second main() the first main() is called again and again (infinite times). Therefore, everything written in between these two mains gets also executed repeatedly.
That's why "hi" is printed infinite time.
+ 2
that is C program to print "Hi" on screen for more details
https://www.sololearn.com/learn/1344/?ref=app
+ 1
actually output is
hihihihi....
infinite times
CAN ANYONE EXPLAIN WHY??
+ 1
#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}
+ 1
i actually not get to know what is happening due to second main()
CAN ANYONE HELP ME TO FIND OUT??
+ 1
thanks Curios Basant❄️
0
Hi
0
The second main function might be causing it...
You can try running it without and see what happens
- 1
hi