Calculate area of a square in C
scanf() - Question 11
In this question, we will see how to input side of a square in C programming using the scanf() function and find its area. To know more about scanf() function click on the scanf() function lesson.
Q11) Write a program in C to input side of a square and find its area.
Formula: area = side * side
Program
#include <stdio.h>
#include <conio.h>
int main()
{
int s,a;
printf("Enter side of a square ");
scanf("%d",&s);
a=s*s;
printf("Area=%d",a);
return 0;
}
Output
Enter side of a square 5 Area=25