Cube Root of a Number || Cube Root Program in C++||C++

In this, we are going to  find cube root of a number with the help of C++ program.


The Code given below can be used in Turbo C++ Compiler.


// Cube root of a number
#include<iostream.h>
#include<conio.h>
#include <math.h> 
// this is necessary for power, sqrt, cbrt etc...

void main()
{
    clrscr();
    int perfectCube = 27;
    int nonPerfectCube = 12;
    int c = cbrt(perfectCube);
    float d = cbrt(nonPerfectCube);
    cout<<"Cube root of "<<perfectCube<<" : "<<c<<endl;
    cout<<"Cube root of "<<nonPerfectCube<<" : "<<d<<endl;
    getch();
}

  

The Code given below can be used in g++/gcc Compiler.

// Cube root of a number
#include<iostream>
#include <math.h> 
// this is necessary for power, sqrt , cbrt etc...
using namespace std;

int main()
{
    int perfectCube = 27;
    int nonPerfectCube = 12;
    int c = cbrt(perfectCube);
    float d = cbrt(nonPerfectCube);
    cout<<"Cube root of "<<perfectCube<<" : "<<c<<endl;
    cout<<"Cube root of "<<nonPerfectCube<<" : "<<d<<endl;
    return 0;
}
  
  
#ENJOY CODING

Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post