this is my first question. I'm really new to programming and I'm struggling when it comes to discerning from well structured code from WTF codemonkey code. Is there anything I should have done different when creating this ubber simple program? My main concern is regarding the function.
#include <iostream>
using namespace std;
void enter_numbers ( int & iNum1, int & iNum2 ) {
cout << "Enter first number" << endl;
cin >> iNum1;
cout << "Enter second number" << endl;
cin >> iNum2;
}
float calc_avg ( int iNum1, int iNum2){
float fRes;
fRes =(float)(iNum1 + iNum2)/2;
return fRes;
}
void show_avg ( float fRes ) {
cout << "Average is: " << fRes;
}
void main () {
int iNum1;
int iNum2;
enter_numbers ( iNum1, iNum2);
float fRes = calc_avg (iNum1, iNum2);
show_avg ( fRes );
fflush(stdin);
getchar ();
}