0
Can anyone explain this code
#include<stdio.h> int main(){ static int i=5; if(--i){ printf("%d",i); } main(10); return 0; }
5 Answers
+ 3
Vanshika Dharwal you are calling main() recursively inside of main() function itself without a base case so this should definately end up in a infinity loop.
And also "i" is declared as static so it will not reinitialise everytime you are calling the main function thus will result in numbers till minus infinity (i.e. wherever int data type allows)
+ 2
shubham kumar surprisingly this does not generate any error.đ
https://code.sololearn.com/c5c2c1R7LZFQ/?ref=app
I think the reason behind this is that main actually can take some arguments but they are generally provided by the operating system(or by programmer using command line arguments)
And according to latest C/C++ standards , " The function main shall not be called explicitly within a program "
+ 1
Thank you đ
+ 1
Your welcome đđ
0
I think there will be error because in the main you placed argument.