Calculate Cube of decimal number in C/C++

Following code calculate the cube of any number in C and C++ language. Just write or copy the code in Turbo C IDE, compile and execute it.

C Source Code

#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr ();
int num,cube=0;
printf("Enter Number to calculate the cube=");
scanf ("%d",&num);
cube = num*num*num;
printf ("cube of Number:%d = %d",num,cube);
getch();
}

Output

image

C++ Source Code

#include<stdio.h>
#include<conio.h>
#include<iostream.h>
void main()
{
clrscr ();
int num,cube=0;
cout<<"Enter Number to calculate the cube=";
cin>>num;
cube = num*num*num;
cout<<"cube of Number of:"<<num<<" is "<<cube;
getch ();
}

 

Output

image

Be Sociable, Share!

One response to Calculate Cube of decimal number in C/C++

Leave a Reply