Advertisement

Pragram to print cube of given number

 Let's see a simple example of c language that gets input from the user and prints the cube of the given number


#include<stdio.h>

int main(){

int number;

printf("enter a number:");

scanf("%d",&number);

printf("cube of number is :%d",number*number*number);

return 0;

}


Output

enter a number:5

cube of number is:125


The scanf("%d",&number) statement reads integer number from the console and stores the given value in number variable.


The printf("cube of number is:%d",number*number*number) statement prints the cube of number on the console.


Redmi Note 10T

Post a Comment

0 Comments