edited by
1,040 views
1 votes
1 votes

main 
{
  int i;
  printf (“Hellow \n”);
  For(i=1; j<=10; i++)
        main ( );
}
What is the o/p of the following program?

  1.   Endless execution of code & printing Hellow continuously
  2.   Compiler error
  3.  Hellow 10 time
  4.   Hellow 9 times
edited by

2 Answers

Best answer
1 votes
1 votes
Inside the main function , it will print Hello, then for the loop from i=1 to 10, it will execute main i.e. it will print Hello 10 times then again it will print Hello another 10 times and will continue printing endlessly
selected by
1 votes
1 votes

Endless execution of code & printing Hellow continuously
Explanation:
When control enters in main( ) it meets printf( ) & promptly prints the message. Then in for loop it calls main again. Recursion starts for i=1. Again there will be a print execution & for i=1, the recursion repeats. This goes on & on until either we don’t abort the execution by pressing ctrl+C.

Related questions

0 votes
0 votes
0 answers
2
srestha asked Mar 7, 2018
612 views
#include<stdio.h int fun1(int x) { x=14; } int fun2(int x) { x=20; } int main() { int(*p)(),m,n; scanf("%d",&m); if(m) p=fun1; else p=fun2; n=(*p)(); printf("%d",n); retu...
0 votes
0 votes
0 answers
3
srestha asked Mar 6, 2018
407 views
#include<stdio.h int main() { char a[]={'A','B','C','D'}; char *p=&a[0]; *p++; printf("%c%c",*++p, *p); }What will be the output?1)C B2)B B3)B A4)C A
0 votes
0 votes
0 answers
4
Parshu gate asked Dec 5, 2017
502 views