What happen when we not use void main? | SoloLearn: Learn to code for FREE!

+20

What happen when we not use void main?

4/4/2018 11:48:20 AM

Puneet Bhardwaj

65 Answers

New Answer

+38

Void return type for main has never been part of the C standard. Use int main. As stated here: http://www.stroustrup.com/bs_faq2.html#void-main

+13

main() function runs your program. Without it there is nothing to do. You can use int main() instead of void main() if you want the program to return a value.

+8

There will be no entry point to the programe

+8

404 NoT found

+7

The program simply won't start. It is useful for creating implementation of header files.

+7

nothing will be executed .

+6

we can use int main also. but there should be main function in our program. The C program is designed in such a way that the execution starts only from a main function. so if you don't give any main function the execution won't happen and the program will not run . Normally we use void run as our simple program does not require to return any value.

+4

Since the execution of any program starts from main() function it is must for any program. If you do not used main() in your program, the program won't be executed. And we know that every function returns a value, it is necessary to write "void" indecating that the function will not return any value. You may use int.

+4

main() is similar to any other kind of function , the difference is , usually other function are user defined but main() is built in function which helps is starting the program execution.

+4

I think we use Void main() in turbo c++...which is not used now !! so using void main() in C++ 11 will cause an error !!

+4

Value stored in memory will be used if you don't use it.

+4

main() is the main method or behaviour of the program which defines how or what task the program has to perform you should use int main() if you want the program to return a value as stated in the courses but as far as i know void main() can be used when you don't want the program to return a value I don't have a lot of knowledge about c proggraming but i have a little through the sololearn course so, please correct me if i am wrong anywhere

+4

your program starts executing from main() function. If you wouldn't use main the program won't run.

+3

in the very old times, the main() in C was always void. it works even here. but since I was not in the C language development loop, and missed when int became a standard. https://code.sololearn.com/ci7g0CdGa4ja/?ref=app

+3

First of all main() method is compulsory in any programme (as the programme starts execution from main() method) void is used because main() method does not return under normal circumstance but if you want to return any values you are free to use int main()......... so we use void main() { }

+3

A C program can run even without any return type as int will be treated as default one. As for not using a main() in a program, the program will not execute but we can use such for header implementations...

+3

it will shows the error

+3

void is return nothing and main is also returned type () function but it depends upon the function calling . If you not use main () function then operating system will not able to execute the programme so use there int main () function.

+3

Program execution starts with main function so its mandatory that every program should have main function. only choice is whether to use void or int

+2

main is a function and if you do not use viod your compiler show u an error