Loading [MathJax]/jax/output/HTML-CSS/config.js

C++ Program To Compute Square And Cube Of Number

C++ Program To Compute Square And Cube Of Number

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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// 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;
}
// 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; }
// 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