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...


how does a main() in C++ is different from main() in C?

Answers were Sorted based on User's Feedback



how does a main() in C++ is different from main() in C?..

Answer / seetha

hello kunal... ur answer was simply wrong..
becoz in both c and c++ also if v use like int main() and
the absence of return 0;
will give only warning message to us... i just complied and
telling this...
if u want to check me... you just compile in both the
language and tell......
without knowing answers pls dont update urself....

Is This Answer Correct ?    29 Yes 12 No

how does a main() in C++ is different from main() in C?..

Answer / yj

First of all, make it clear that whenever we run any program the compiler search for the main() function to start execution...
Now,
The programming language C follows top down approach. Means the control moves from top to down. Hence in this we have to give main function above all the other lines of code...
But when you program in C++ which follows bottom up approach i.e., the control moves from bottom to up...For example, when we make a function in C++ we give its definition above main() and when we call that function in main(): as soon as the compiler encounter the "calling line"...the compiler now search for the definition of that function which is above the function main(). Now u visualise that the control is moving from bottom to up.

Hence,
"The function main() in C has to be given at the top. But in C++the function main can be at the bottom also"

Is This Answer Correct ?    25 Yes 13 No

how does a main() in C++ is different from main() in C?..

Answer / vishal palan

In C the main() does not return any value by default. But in C++ the main() returns value int by default.
Again
In U can complie progm by writing main(){....}
But in C++ u have to return int main() {...return 0;}
or void main() {...}

Is This Answer Correct ?    16 Yes 13 No

how does a main() in C++ is different from main() in C?..

Answer / shivam

in c++ this approach is based on the concept of clint server model . the class definition including the member functions cositute the server that provides services to the main() main function program in c the program starts from main()

Is This Answer Correct ?    0 Yes 0 No

how does a main() in C++ is different from main() in C?..

Answer / jit

In C if we write a program like
int main()
{
static int i = 5;
if (--i){
printf("%d ", i);
main(10);
}
}

It works but not in C++

Is This Answer Correct ?    0 Yes 1 No

how does a main() in C++ is different from main() in C?..

Answer / hamza

in C++, you do not need to type "return 0;" statement in a [ int main() {} ]as it will be provided automatically but not in case of C.

Is This Answer Correct ?    22 Yes 32 No

how does a main() in C++ is different from main() in C?..

Answer / bhanu

in c main() is a function, in c++ main() a class

Is This Answer Correct ?    8 Yes 24 No

Post New Answer

More OOPS Interview Questions

What is encapsulation oop?

0 Answers  


where is memory for struct allocated? where is memory for class-object allocated? I replied for struct in stack and for class-object in heap. THen he asked if class has struct member variable what happens.class on heap and what about struct in that class? couldnt ans :( :-?

2 Answers   Infosys, Microsoft,


What is a function in oop?

0 Answers  


Which is faster post increment or pre increment ? and in which cases should u use either - to increase speed?

4 Answers   EA Electronic Arts,


Tell me the scenario,Where we can use interfaces or Abstract class.And What is the difference between interfaces and abstract class?

5 Answers  


i got a backdoor offer in process global,Bangalore..Can i work with it?

0 Answers  


#include <iostream> using namespace std; struct wow { int x; }; int main() { wow a; wow *b; a.x = 22; b = &a; a.x = 23; cout << b->x; return 0; }

1 Answers  


Definition of Object Oriented Programming in single line?

33 Answers   Impact Systems, Q3 Technologies, TCS,


write a program to find the largest of two numbers without using for,while,switch,if else, conditional operator and do while using c++ pgmng language

3 Answers   Satyam,


What is a null tree?

0 Answers  


what about you? wahat is your object? introduce your self?

1 Answers   Ajmal Perfumes, TCS,


What is a class and object?

0 Answers  


Categories