Wednesday, November 4, 2009

Simple Square Program

this is a simple program to return a square value of the number 27

#include <iostream>


using namespace std;


int Square(int);  // declare that function returns
 // an int and takes an int
int Cube(int);


int main()
{
cout << "The square of 27 is " << Square(27) << endl;
cout << "The cube   of 27 is " << Cube(27)   << endl;
return 0;
}


int Square(int n)
{
return n * n;
}


int Cube(int n)
{
return n * n * n;
}


simple right?

now I want u to make this program to receive user input. meaning, user can input any number, not just 27.

pretty simple right?

No comments:

Post a Comment