Hi
Personally I would prefer to give function's definition before making calls to it because it provides more understanding how C++ works. As some member here told me that time-travel (moving back and forth) is not possible all the time in C++. The statements are executed in a sequence so we should also try to write the code in a sequence to make it more understandable.
for(int j=0; j<45; j++) - The for loop is executed, then it's value is incremented, then the incremented value is checked against the test expression. So, don't you think having the syntax this way, for(int j=0; j++; j<45), makes more sense?
Please help me. Thanks a lot.
Code:
// table.cpp
// demonstrates simple function
#include <iostream>
using namespace std;
void starline(); //function declaration
// (prototype)
int main()
{
starline(); //call to function
cout << "Data type Range" << endl;
starline(); //call to function
cout << "char -128 to 127" << endl
<< "short -32,768 to 32,767" << endl
<< "int System dependent" << endl
<< "long -2,147,483,648 to 2,147,483,647" << endl;
starline(); //call to function
return 0;
}
//--------------------------------------------------------------
// starline()
// function definition
void starline() //function declarator
{
for(int j=0; j<45; j++) //function body
cout << '*';
cout << endl;
}