What is the difference between int main () and void main ()?

In C++, both fun() and fun(void) are same. So the difference is, in C, int main() can be called with any number of arguments, but int main(void) can only be called without any argument. Although it doesn't make any difference most of the times, using “int main(void)” is a recommended practice in C.

Likewise, what is the use of void Main?

Actually, 'main' is the parent function of all the functions in C. If we don't need any return value we use return type 'void'. We can also use ' int' as a return type. After all 'main()' is also a function, there is a flexibility of mentioning return type to it by user.

What is the difference between main and void Main?

So the difference is, in C, int main() can be called with any number of arguments, but int main(void) can only be called without any argument. Although it doesn't make any difference most of the times, using “int main(void)” is a recommended practice in C. Exercise: Predict the output of following C programs.

What is a void in C?

The Void type, in several programming languages derived from C and Algol68, is the type for the result of a function that returns normally, but does not provide a result value to its caller. Usually such functions are called for their side effects, such as performing some task or writing to their output parameters.

You May Like Also

  • What is a function in C++?
  • What is the meaning of void Main?
  • What does int main () mean?
  • What is the difference between potential and potential difference?
  • What is the difference between absolute and relative difference?
  • What are the differences between urban and rural areas?
  • What is the difference between their and there?
  • What is the difference between should and ought to?
  • Which is correct different from or different to?
  • Who said the past is a foreign country they do things differently there?
  • Which is correct different to or different from?
  • What is the difference between difference?