Write a program to take value of length and calculate area of a square. Length=7
Answers
Answer:
C Program to find the area of a square
To calculate area of a square, we need length of any side of a square. Below program, first takes length of side as input from user using scanf function and stores in a floating point variable. To find the area of square we multiple the length of side with itself and store area in a floating point variable. At last, it prints the area of square on screen using printf function.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/*
* C Program to calculate area of a square
*/
#include <stdio.h>
#include <conio.h>
int main(){
float side, area;
printf("Enter length of side of square\n");
scanf("%f", &side);
/* Area of Square = Side X Side */
area = side * side;
printf("Area of square : %0.4f\n", area);
getch();
return 0;
Explanation: