Write a C, C++ program to print square of a number. We have to write a code in which our program will take an input number and print it's square.

Similar programming questions for practice.

Calculate cube of a number

Find sum of first n odd numbers

Program to check perfect square of a number

Similar programming questions for practice.

Calculate cube of a number

Find sum of first n odd numbers

Program to check perfect square of a number

## C Program to Print Square of a Number

#include<stdio.h> int main() { int num, sqr; printf("Enter a number \n"); scanf("%d", &num); // calculate square of a number sqr = num * num; printf("Square of an input number is %d", sqr); return 0; }

## C++ Program to Print Square of a Number

#include <iostream.h> using namespace std; int main() { int num,sqr; cout << "Enter a number \n"; cin >> num; // Calculate square of a number sqr = num * num; cout << " Square of a number is " << sqr; return 0; }

**Output:**

**Enter number : 6**

Square of a number is : 36

## 0 comments:

## Post a Comment