Gangadhari Pavan Siddhartha
3 months ago
Gangadharicountry asked

Can you explain when we should use int main() versus void main()?

Sarthak Baral
Expert
last month
Sarthak Baral answered

Hi Gangadhari,

In C, you should use int main() because main is supposed to return an integer status code to the operating system.

Example:

int main() {
    return 0;
}

void main() is not standard C, so it is best to avoid it.

If you have more questions, I am here to help 😊

C
This question was asked as part of the Learn C Programming course.