C Program to Find Cube Root of Any Number

Advertisements

Prev Tutorial Next Tutorial

Find Cube Root of Any Number Program in C

To find cube root of any number we need to find 1/3 power of any number. For example if you need to find cube root of 27 then calculate 1/3 power of 27, result is 3.

Find Cube Root of Any Number Program in C

#include<stdio.h>
#include<conio.h>
#include<math.h>

void main() 
{ 
int num, ans; 
clrscr(); 
printf("Enter any number: "); 
scanf("%d",&num); 
ans=pow(num, 1.0/3.0);
ans++;
printf("\n\Cube of %d is: %d",num,ans); 
getch(); 
}

Output

Enter any number: 27
Cube of 27 is: 3

Explanation of Program

  • Here we receive any number from keyboard and after that we find 1.0/3.0 power of number because square root of any number means power of 1/3.
  • pow() is a predefined function in math.h header file, it is used for calculate power of any number.

Cube Root of Number using user defined function

Cube root of a number

#include<stdio.h>
#include<conio.h>
#include<math.h>

int cube(int); 
void main() 
{ 
int num; 
clrscr(); 
printf("Enter any number: "); 
scanf("%d",&num); 
printf("\n\Cube of %d is: %d",num,cube(num)); 
getch(); 
} 
int cube(int num) 
{ 
int ans; 
ans=pow(num, 1.0/3.0);
ans++; 
return(ans); 
getch(); 
}

Output

Enter any number: 64
Cube of 64 is: 4

Explanation of Program

  • Here we receive any number from keyboard and after that we find 1.0/3.0 power of number because square root of any number means power of 1/3.
  • pow() is a predefined function in math.h header file, it is used for calculate power of any number.

Prev Tutorial Next Tutorial

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements