Gangadhari Pavan Siddhartha
5 months ago
Gangadharicountry asked

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

Sarthak Baral
Expert
3 months ago
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.