Main and Void | SoloLearn: Learn to code for FREE!

+4

Main and Void

can you tell me what is diffrence and function between main() and void(),please i'm still confused

3/14/2017 3:32:34 AM

AryaJ

7 Answers

New Answer

+5

what is void()??? void has never been a method/function.

+5

Basically, if you learnt till methods/functions, every method have to give back something when you call it. But some methods are there to do some stuff that doesnt give back a value, hence you call it a void method, or a method that returns a void.

+4

main is a function void is a datatype

+3

what do you mean doesn't return any value ? can you tell me more details, please

+2

Ur question itself little bit confusing but let me try. Program starts from main function ( it's the starting function/point) Void implies that method doesn't return any value.

+2

Well, main() is main method and it is must in c, c++, java. From it all execution start, if any other method in not link with main directly or indirectly. Then it will not execute. And there is not specific method call void but you can create a method name void. But can you tell me in which language.

+2

In method signature we define whts the return type of the function/method. int add (int a,int b){ return a+b; } //Returns integer - sum of a and b string getValue (){ return "My Value"; } //Returns string void print(){ Console.WriteLine("Hello World"); } //no return value just print on console(C#)