Which of the following statements is correct about the program given below? #include void main() { int i=0; i++' If(i<=3) { printf(“I am the best”); exit();main(); } }
Reveal answer
Fill a bubble to check yourself
Which of the following statements is correct about the program given below? #include void main() { int i=0; i++' If(i<=3) { printf(“I am the best”); exit();main(); } }
<span style="font-size:11.0pt;line-height:115%;font-family:"Calibri","sans-serif";mso-ascii-theme-font:minor-latin;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:"Times" new="">The program prints 'I am the best' three times.
<span style="font-size:11.0pt;line-height:115%;font-family:Calibri,sans-serif;mso-ascii-theme-font:minor-latin;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:Times" new="">The program prints 'I am the best' infinite times.
<span style="font-size:11.0pt;line-height:115%;font-family:Calibri,sans-serif;mso-ascii-theme-font:minor-latin;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:Times" new="">The program prints 'I am the best' only once.
<span style="font-size:11.0pt;line-height:115%;font-family:Calibri,sans-serif;mso-ascii-theme-font:minor-latin;mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:Times" new="">The compiler reports an error since main() cannot call itself.
This option is correct because when the compiler prints 'I am the best' for the very first time, it subsequently reads exit() and the program execution comes to an end. Hence, the statement will be printed only once.