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

+3

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

Christian0972

9 Answers

New Answer

+8

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)

+9

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++.

+5

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

+4

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

+4

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

+3

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

+3

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.

+3

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

+3

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