0d: 00h: 00m: 00s

🎁 Get 3 extra months of learning β€” completely FREE

That's 90 extra days to master new skills, build more projects, and land your dream job.

Become a PRO
Background Image

🎁 Get 3 extra months of learning completely FREE

Become a PRO
Gangadhari Pavan Siddhartha
2 months ago
Gangadharicountry asked

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

Sarthak Baral
Expert
yesterday
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.