C++ Program To Compute Square And Cube Of Number

Write C++ Program to Find Square and and Cube of Given Number

// Write C++ program to print number, its square and cube

#include<iostream>

using namespace std;

int main()
{
     long n,square,cube;

     cout << "Enter the number :--> " ;
     cin >> n ;

     square = n * n;
     cube = n * n * n;

     cout << "Square of the number :--> " << square ;
     cout << "\nCube of the number :--> " << cube ;

    return 0;
}

Output:

Enter the number :–> 5

Square of the number :–> 25
Cube of the number :–> 125


<< Previous | Next >>