This is a simple program for beginners to find square and cube of any given number using C.
is multiplication of number by same number. If the number is 5, then square number x number, that is 5 * 5 = 25. (In keyboard, key ’*’ is used for multiplication).

C Program Code:

#include <stdio.h>
#include <conio.h>
#include <stdlib.h> void main()
{
int num, squar;
printf("Enter a number: ");
scanf("%d", &num);
squar = num*num;
printf("Square of number %d is %d",num,squar);
getch();
}

Sample Output: In case of cube, similar to square, you need to multiplying the number once again, that is number * number * number.

C Program Code:

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
void main()
{
int num, cube;
printf("Enter a number: ");
scanf("%d", &num);
cube = numnumnum;
printf("Cube of the number %d is %d", num,cube);
getch();
}

Sample Output:

You may combine both cube and square programs together. So you can simply find both square and cube of given number using a simple program code.

#include <stdio.h>
#include <conio.h>
#include <stdlib.h> void main()
{
int num, square, cube;
printf("Enter a number: ");
scanf("%d", &num);
square = num * num;
cube = numnumnum;
printf("Square of the number %d is %d", num, square);
printf("\nCube of the number %d is %d", num, cube);
getch();
}

Sample Output: Find square and cube of given number in c programming