Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- //Functions
- int Square(int);
- int Cube(int);
- int main()
- {
- //Variables
- int num; //user input
- int square; //Holds the square of num
- int cube; //Holds the cube of num
- //Purpose
- cout << "Purpose of the program: To take a user input, and display the square, and cube of it." << endl;
- //Get input
- cout << "Please enter an integer: ";
- cin >> num;
- cout << "You have entered: " << num << endl;
- //Compute the square and cube
- square = Square(num); //Calls the Square function
- cube = Cube(num); //Calls the cube function
- //Display the square and cube of a number
- cout << "The square of " << num << " is " << square << endl;
- cout << "The cube of " << num << " is " << cube << endl;
- return 0;
- }
- int Square(int x)
- {
- return x * x;
- }
- int Cube(int x)
- {
- return x * x * x;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement