Dremendo Tag Line

Print square and cube of a number in C

printf() - Question 12

In this question, we will see how to print the square and cube of a number in C programming using the printf() function. To know more about printf() function click on the printf() function lesson.

Q12) Write a program in C to print the square and cube of int a=8.

Program

#include <stdio.h>
#include <conio.h>

int main()
{
    int a=8;
    printf("Square of %d=%d\n",a,a*a);
    printf("Cube of %d=%d",a,a*a*a);
    return 0;
}

Output

Square of 8=64
Cube of 8=512
video-poster