Whether there can be main inside another main?If so how does
it work?
Answers were Sorted based on User's Feedback
Answer / namita
main()
{
main();
}
This code snippet will result in infinite loop.
Is This Answer Correct ? | 43 Yes | 15 No |
Answer / divyansh
main marks the beginning of a program, 2 direct mains can't
be there as it will make the compiler dumb!(literally),in
this case it will give an error, or an infinite loop
operation will be executed.
Is This Answer Correct ? | 21 Yes | 3 No |
Answer / nilanjan
Surely. . It will just act like a recursive version of
main(), which will run infinite times if there is no
limiting condition specified.
Sample:
#include <stdio.h>
int main()
{
int static i = 0;
printf("\nFile is too big.");
while(i == 0)
{
i++;
main();
}
return 0;
}
Is This Answer Correct ? | 21 Yes | 3 No |
Answer / vara
there will be no error but the output will go in infinite
loop
main()
{
int a=2,b=3;
a=a+b;
b=a-b;
a=a-b;
printf("%d",&a);
printf("%d",&b);
main();
getch();
}
Is This Answer Correct ? | 19 Yes | 5 No |
Answer / rajdesai143
yes.There can be any no of main inside the main.But one
static main should be required .In that we can call any no
of times it just works as recursive.
Since one static main is required because (astart) requires
that . Its a startup code
Is This Answer Correct ? | 9 Yes | 0 No |
Answer / gprabha
#include<stdio.h>
void main()
{
printf("main()");
main();
getch();
}
Is This Answer Correct ? | 3 Yes | 1 No |
Answer / harinath
yes there can be
for example
main()
{
static int count=50;
printf("%d",count--);
while(count>0)
main();
}
here the output is numbers upto 1 then it comes out of it.
Is This Answer Correct ? | 1 Yes | 1 No |
#define MAX 3 main() { printf("MAX = %d ",MAX ); #undef MAX #ifdef MAX printf("Vector Institute”); #endif }
What library is sizeof in c?
Explain argument and its types.
send me the code of flow chart generator using C-programming language amd this code should calculate the time and space complexity of the given progran and able to generate flowchart according to the given program?
how to return 1000 variables from functio9n in c?plz give me code also
identify the in correct expression a.a=b=3=4; b.a=b=c=d=0; float a=int b=3.5; d.int a; float b; a=b=3.5;
What is the g value paradox?
consider the following structure: struct num nam{ int no; char name[25]; }; struct num nam n1[]={{12,"Fred"},{15,"Martin"},{8,"Peter"},{11,Nicholas"}}; ..... ..... printf("%d%d",n1[2],no,(*(n1 + 2),no) + 1); What does the above statement print? a.8,9 b.9,9 c.8,8 d.8,unpredictable value
regarding the scope of the varibles;identify the incorrect statement: a.automatic variables are automatically initialised to 0 b.static variables are are automatically initialised to 0 c.the address of a register variable is not accessiable d.static variables cannot be initialised with any expression
In scanf h is used for
consider the following C code main() { int i=3,x; while(i>0) { x=func(i); i--; } int func(int n) { static sum=0; sum=sum+n; return(sum); } the final value of x is
A C E G H +B D F A I ------------ E F G H D