Main and Void | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Main and Void

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

14th Mar 2017, 3:32 AM
AryaJ
AryaJ - avatar
7 Answers
+ 5
what is void()??? void has never been a method/function.
14th Mar 2017, 3:48 AM
Wen Qin
Wen Qin - avatar
+ 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.
14th Mar 2017, 3:56 AM
Wen Qin
Wen Qin - avatar
+ 4
main is a function void is a datatype
14th Mar 2017, 8:19 AM
Shirious
Shirious - avatar
+ 3
what do you mean doesn't return any value ? can you tell me more details, please
14th Mar 2017, 3:54 AM
AryaJ
AryaJ - avatar
+ 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.
14th Mar 2017, 3:52 AM
Eranga
Eranga - avatar
+ 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.
14th Mar 2017, 4:00 AM
Aditya kumar pandey
Aditya kumar pandey - avatar
+ 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#)
14th Mar 2017, 4:01 AM
Eranga
Eranga - avatar