In this program we are dealing with the square and cube of a number here, we have already
initialised the value of n as 10 and calculating square and cube accordingly and displays
the result on the screen by printf() function. So by making this simple program we can
calculate square and cube of any number and here we can also ask for input by just adding
a simple scanf() function for scanning value from user.
Program
#include<stdio.h>
#include<conio.h>
int main()
{
int n=10,cube,square;
cube= n*n*n;
square=n*n;
printf("Cube of the number
is = %d\n",cube);
printf("Square of the number is = %d",square);
return 0;
}
Output:
here, \n is used to get output in separate lines as you can see in the output window.
Post a Comment