#include<stdio.h>
#include<conio.h>
int main()
{
int a,c;
printf("\n Enter any number");
scanf("\n %d",&a);
c=a*a;
printf("\n Square of given no=%d",c);
getch();
}
The above program takes an integer input from the user using scanf
function and stores it in the variable a
. The square of the number is calculated by multiplying the number with itself, and the result is stored in variable c
.
Finally, the printf
function is used to print the square of the number in the console window using the format specifier %d
. The getch
function is used to hold the console window until the user presses a key.
The program calculates the square of an integer number entered by the user and displays the result on the screen.
Thanks
Write a program to find the square of the given number.