Menu Close

Calculate the Cube Root

Ramu is collecting some random inputs from his maths teacher.Help ramu to

calculate the cube root of the user input by using C++ program.
Input: Get the integer number as input.
Output: Print the cube root of the input number.
Refer the following sample input and output.

Input : 27

Output : 3
#include <iostream>
#include<math.h>
using namespace std;

int main()
{
  int x,y;
  cout<<"Enter the integer : ";
  cin>>x;
  y=cbrt(x);
  cout<<y;
  return 0;
}

Input_1:
Enter the integer : 8

Output:
2


Input_2:
Enter the integer : 64

Output:
4


Input_3:
Enter the integer : 125

Output:
5


Input_4:
Enter the integer : 216

Output:
6


Input_5:
Enter the integer : 343

Output:
7


Illustration of the Output:

Executed using g++ linux

More Q