Dremendo Tag Line
t

Print square and cube of a number in C++

cout - Question 12

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

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

Program

#include <iostream>
#include <conio.h>

using namespace std;

int main()
{
    int a=8;
    cout<<"Square of "<<a<<"="<<a*a<<endl;
    cout<<"Cube of "<<a<<"="<<a*a*a;
    return 0;
}

Output

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