SOURCE FILE: my_example.cpp
#include <iostream.h>
// THINK ABOUT THE OUTPUT THAT EACH STATMENT PRODUCES
void DoTimes(int yourNumber)
{
cout << "One times " << yourNumber << " makes " << 1 * yourNumber << endl ;
cout << "Two times " << yourNumber << " makes " << 2* yourNumber << endl ;
cout << "Three times " << yourNumber << " makes " << 3* yourNumber << endl ;
cout << "Four times " << yourNumber << " makes " << 4* yourNumber << endl ;
cout << "Five times " << yourNumber << " makes " << 5* yourNumber << endl ;
cout << "========================" << endl << endl ;
}
int Square (int yourNumber)
{
int s_temp ;
s_temp = yourNumber * yourNumber ;
return s_temp ;
}
int main(void)
{
int n, m ;
cout << endl ; // skip a line in the output
cout << "One and One are: " << 2 << endl;
cout << "Two and Two are: " << 2 + 2 << endl;
cout << "Six times Eight makes: " << 6*8 << endl;
cout << endl ; // skip a line in the output
m = 4 ;
/* Note: no problem here that m is not called yourNumber --
the name of the formal parameter to function DoTimes(). */
DoTimes(m) ;
DoTimes(12) ;
DoTimes(m*5) ;
n = Square(15) ;
cout << endl ; // skip a line in the output
cout << "The square of 15 is: " << n << endl ;
cout << endl ; // skip a line in the output
cout << "What number is this? " << 14 - 10 / 2 + 8 << endl ;
cout << "What number is this? " << (14 - 10) / 2 + 8 << endl ;
cout << "What number is this? " << 14 - 10 / (2 + 8) << endl ;
cout << "What number is this? " << (14 - 10) / (2 + 8) << endl ;
cout << endl ; // skip a line in the output
return 0;
}