Int main() | Sololearn: Learn to code for FREE!


Int main()

I understand what this means but I don’t understand why there is the () after it. I am pretty sure that I need it, I’m just wondering why

11/13/2019 8:20:57 PM


9 Answers

New Answer


Christian0972 because "main" is a function and this is how a function should be defined <Return type><function name>(<parameters>) Int main() Means "main" function will return integer value but will not need argument to be executed(or we can say that it will need "void" to be executed)


Ace In C++ int main() or no parameter in function fun() means, the function does not take any parameters by default. What you said is true for C i.e no parameters means any number of parameters, hence you need to write fun(void) or main(void). Writing void is unnecesary in C++.


Ace Yes thats right i forgot to say that. I was only talking about the case when you dont want to use the arguments.


~ swim ~ Oops I misread the tagged languages. My answer is irrelevant then. Deleted


the functions return an example sum value (int a, b) this function will return the sum of a and b the parenticis "()" main function indicates that they do not return any value in the sololean course c there are lessons about the functions


Because this function has no parameter. Always when you define a function on your own without parameters you would also put () behind the name


If you don't put, it becomes a variable. if you put, it refers to as a function, so a function should have (). A main() is also a function and starting point of program execution.


Ace Sorry I didn't want you to delete your answer but your decision and I respect it. 👍🙂


Everything in c starts with main function ,we use paranthesis for function Syntax