Programming Examples

Write a program to find perfect cubes up to a given number


Write a program to find perfect cubes up to a given number.

/ 1, 8, 27, 64 are perfect cubes of 1, 2, 3 and 4 /.

Solution

# include<math.h>
void main()
{
int i, j, k;
clrscr();
printf(“Enter a Number :”);
scanf(“%d”,&k);
for(i=1;i<k;i++)
{
 for(j=1;j<=i;j++)
 {
 if(i==pow(j,3))
 printf(“\nNumber : %d & it’s Cube :%d”,j,i);
 }
}
getch();
}
Output

OUTPUT:

Enter a Number : 100

Number : 1 & it’s Cube : 1

Number : 2 & it’s Cube : 8

Number : 3 & it’s Cube : 27

Number : 4 & it’s Cube : 64

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz