Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Whether there can be main inside another main?If so how does
it work?

Answers were Sorted based on User's Feedback



Whether there can be main inside another main?If so how does it work?..

Answer / namita

main()
{
main();
}

This code snippet will result in infinite loop.

Is This Answer Correct ?    43 Yes 15 No

Whether there can be main inside another main?If so how does it work?..

Answer / shiva

main()
{
printf("main()");
}

Is This Answer Correct ?    39 Yes 19 No

Whether there can be main inside another main?If so how does it work?..

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

Whether there can be main inside another main?If so how does it work?..

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

Whether there can be main inside another main?If so how does it work?..

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

Whether there can be main inside another main?If so how does it work?..

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

Whether there can be main inside another main?If so how does it work?..

Answer / kasthurimangai.v

main()
{
printf("main()");
}

Is This Answer Correct ?    8 Yes 3 No

Whether there can be main inside another main?If so how does it work?..

Answer / gprabha

#include<stdio.h>
void main()
{
printf("main()");
main();
getch();
}

Is This Answer Correct ?    3 Yes 1 No

Whether there can be main inside another main?If so how does it work?..

Answer / guest

nested main

Is This Answer Correct ?    1 Yes 0 No

Whether there can be main inside another main?If so how does it work?..

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

Post New Answer

More C Interview Questions

How is a macro different from a function?

0 Answers   Tech Mahindra,


How. To pass the entrance test

1 Answers   Tech Mahindra,


without using control structures and control structures find the max and min of given 2 nos

1 Answers   HCL,


#define MAX(x,y) (x) > (y) ? (x) : (y) main() { int i = 10, j = 5, k = 0; k = MAX(i++, ++j); printf("%d %d %d", i,j,k); } what will the values of i , j and k? }

14 Answers   CDAC, GATE, NDS, TCS,


name the language for writing c compiler?

3 Answers   Microsoft,


Describe dynamic data structure in c programming language?

0 Answers  


why do we use pointer instead directly acessing the data?

2 Answers  


Write a C program to convert an integer into a binary string?

1 Answers  


code for bubble sort?

1 Answers  


How do you sort filenames in a directory?

0 Answers  


Why is c still so popular?

0 Answers  


How can you increase the size of a statically allocated array?

0 Answers   TISL,


Categories