I have a general question - what should a main function look like.
When I program, I only use the main function to link all the other functions
together like this
1 2 3 4 5 6
int main()
{
num1=getNumber();
num2=getNumber();
cout<<add(num1,num2);
}
Generally, I avoid writing the bulk of the program
or "cout<<-ing" in the main function
like this:
1 2 3 4 5 6 7
int main()
{
int num1, num2;
cout<<"enter num1"; cin>>num1;
cout<<"enter num2"; cin>>num2;
cout<<sum(num1,num2);
}
But I've seen quite a few people do that. Which is the accepted approach. I really think the first one looks alot neater.
Going to deep into the structuring of a console program can be tedious and a worthless effort at that. Mostly you will be wanting to write codes that are clear to understand, both given codes are good in this view.
Now, from a bit more practical view, let's say that we want to change our console program into a program with a GUI or similar. The second code would require us to rewrite nearly our entire program, whereas the first only requires us to change some interfacing with said medium (console or GUI).
Generally, try writing in the first way, but for really small programs you have no intention of looking back at (like most console programs, no offense) it will not really matter.
Properly splitting tasks into functions makes code infinitely more clear and makes bugs easier to see/find. When you clump everything into one massive function (main or not) things get very messy and hard to follow.