how does a main() in C++ is different from main() in C?
Answer Posted / 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 |
Post New Answer View All Answers
What are the 4 pillars of oop?
What language is oop?
What is for loop and its syntax?
What is byval and byref? What are differences between them?
What is the purpose of enum?
Following are the class specifications: class {int a}; class {int b}; Using friend funtion,calculate the max of two objects and display it.
What is abstraction example?
What is overloading in oop?
What are the benefits of polymorphism?
write a program using c++ to implement single contiguous memory mangement techniques.display the content of the main memory after yhe allocation of jobs and percentage of the wastage of the main memory
What is overloading in oops?
#include
What is difference between pop and oop?
what are the ways in which a constructors can be called?
Whats is abstraction in oops?