Can you solve write a program in c++ to print cube of the given number | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can you solve write a program in c++ to print cube of the given number

19th Nov 2016, 5:53 AM
Aniket Deshmukh
6 Answers
+ 28
#include <iostream> #include <cmath> using namespace std; int main() { int a; cin >> a; cout << "the cube of" << a << "is" << pow(a, 3) << endl; return 0; } By using pow() function in cmath library you can count any power of a.
19th Nov 2016, 10:15 AM
Rebeka Asryan
Rebeka Asryan - avatar
+ 7
the program is #include <iostream.h> void main() { int a, b; cout<<"enter a no."; cin>>a; b=a*a*a; cout<<"The cube is "<<b; } you can use Rebeccas method too that works for more power it uses math.h and the power function you can make own power function by for loop
19th Nov 2016, 9:27 AM
Sandeep Chatterjee
+ 2
I can give you a hint : The cube of a number is basically itself multiplied by itself thrice. So the cube of a is a*a*a OR a^3.
19th Nov 2016, 8:09 AM
Deformer Gaming
Deformer Gaming - avatar
+ 2
#include <iostream> using namespace std; int main() { int x; int Qube; cout << "enter a number to sube root: " << endl; cin >> x; Qube = x*x*x; cout << "the qube root of your answer is: " << Qube << endl; return 0; }
19th Nov 2016, 9:30 AM
Abdelaziz Abubaker
Abdelaziz Abubaker - avatar
+ 1
read the value of x; and then perform q=x*x*x;
19th Nov 2016, 3:28 PM
BHANU PRAKASH H C
BHANU PRAKASH H C - avatar
0
#include<iostream> using namespace std; int main() { int n; cout<<"Enter a number for which you want to find the cube$ "<<endl; cin>>n; cout<<"Cube of a given number is"<<(n*n*n)<<endl; } cube is three times a number that's it buddy enjoy coding $$$dollars
4th Jun 2017, 4:33 PM
BHANU PRAKASH H C
BHANU PRAKASH H C - avatar