Creating and calling two simple functions to display tables of square numbers and cubic numbers.
Can be compiled and executed on a Raspberry Pi, Apple Mac or Linux PC.
Alternatively you can paste the code into repl.it.
Code below:
// Simple functions - Phil Gardner
#include <iostream>
using namespace std;
// - - - - - - - - - - - - - - - - - - - - -
int cube( int original )
{
return original * original * original;
}
// - - - - - - - - - - - - - - - - - - - - -
int square( int original )
{
return original * original;
}
// - - - - - - - - - - - - - - - - - - - - -
int main()
{
for ( int num = 1; num <= 10; num++ )
{
cout << num << "^2 = " << square( num ) << endl;
}
cout << endl << "- - - - - - - - - - -" << endl << endl;
for ( int num = 1; num <= 10; num++ )
{
cout << num << "^3 = " << cube( num ) << endl;
}
}