Program to print the cube of a number in c-language Method-1 #include<stdio.h> main() { int x,y; printf("Enter the number for cube\n"); scanf("%d",&x); y=(x*x*x); printf ("Cube of the number is=%d",y); } Method-2 #include<stdio.h> #include<math.h> main() { int x,y; printf("Enter the number for cube\n"); scanf("%d",&x); y=pow(x,3); printf ("Cube of the number is=%d",y); } OUTPUT Enter the number for cube 5 Cube of the number=125 This program is perfect example of pow function and also describe the math.h header files. By using this function you can find any power of any number. But in this program it is...
Comments
Post a Comment