Write an algorithm that compute the area of a square
Answers
The program to compute area of a square is :-
#include <stdio.h>
int main()
{
float side, area;
printf("Enter the sides of a square :- ");
scanf("%f",&side);
area= side* side;
printf("Area of a Square is :- %0.2f", area);
}
Output -
Enter the sides of a square :- 2
Area of a Square is :- 4.00
Algorithm -
Step 1 - Start
Step 2 - Declare floating type variables
Step 3 - Read value for side of square
Step 4 - Multiply sides and store the result
area <- side * side
Step 5 - Display area of square
Step 6 - Stop
Answer:
Algorithm for area of a square:
Explanation:
An algorithm is nothing but a set of rules written, which are to be followed in calculations or in other problem-solving operations especially in a computer.
Algorithms are the most important steps in programming.
Algorithms must terminate after a finite number of steps.
Now, the algorithm for the area of a square will be as follows:
START
ACCEPT THE SIDE OF SQUARE SAY a
COMPUTE THE AREA WITH THE HELP OF FORMULA A =
DISPLAY RESULT
STOP