Write a C , C++ program to calculate square of a number. You have to input number and your program print it's square.

Some more problems for practice.

Calculate cube of a number.

Find sum of first n odd numbers.

Program to check perfect square of a number.

Some more problems for practice.

Calculate cube of a number.

Find sum of first n odd numbers.

Program to check perfect square of a number.

## Calculate square of a number in C

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

## Calculate square of a number in C++

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

**Output:**

**Enter number : 6**

Square of a number is : 36

## No comments:

## Post a Comment