Difference between Int Main and Void Main in C/C++ - learnit

Home Top Ad

Post Top Ad

Saturday, April 24, 2021

Difference between Int Main and Void Main in C/C++

Difference between Int Main and Void Main in C/C++

C and C Programming

C and C++ is a powerful general-purpose programming language. It can be used to develop operating systems, browsers, games, and so on. C and C++ supports different ways of programming like procedural, object-oriented, functional, and so on. This makes C and C++ powerful as well as flexible.


Why Learn C++ and C?

C and C++ is used to develop games, desktop apps, operating systems, browsers, and so on because of its performance


After learning C and C++, it will be much easier to learn other programming languages like Java, Python, etc.


C and C++ helps you to understand the internal architecture of a computer, how computer stores and retrieves information.


Difference between Int Main and Void Main in C/C++

Sometimes we use int main(), or sometimes void main(). Now the question comes into our mind, that what are the differences between these two.


The main() function is like other functions. It also takes arguments, and returns some value. One point we have to keep in mind that the program starts executing from this main() function. So the operating system calls this function. When some value is returned from main(), it is returned to operating system.


The void main() indicates that the main() function will not return any value, but the int main() indicates that the main() can return integer type data. When our program is simple, and it is not going to terminate before reaching the last line of the code, or the code is error free, then we can use the void main(). But if we want to terminate the program using exit() method, then we have to return some integer values (zero or non-zero). In that situation, the void main() will not work. So it is good practice to use int main() over the void main().


Please Watching My Video is Below

No comments:

Post a Comment

Post Top Ad