I want to know why we use void if we have to write int main function also

#include
using namespace std;
void HelloWorld(){
cout<<“Hello World”;
}
int main(){
HelloWorld();
cout<<endl;
return 0;
}

hi @discobot hi functions are made to make the code more modular you can use it any no of times, just call it. void is because here u r just printing something and not returning from the function.

int main is the default function, apart from that u can make many other functions with different return types. You’ll understand the importance if making functions later on as u proceed with the course.

Hi! To find out what I can do, say @discobot display help.