Beta Coder

Learn code like Beta Coder.

Breaking

Thursday, January 9, 2020

C Program to Calculate area of a Square

Calculate area of a Square
C Program to Calculate area of a Square

In this program we learn how to calculate area of a square using C.

Area formula of a Square

The area of a square is given by the bellow formula
area= side x side

To compute the area of a square, first if you know the length of its sides.
// calculate area of a squar
#include “stdio.h”
#include “conio.h”
void main()
{
    int s,a;
    clrscr();
    printf("\n Enter lenth of a side : ");
    scanf("%d",&a);
    s=a*a;
    printf("\n The area of squar = %d sq. unit",s);
    getch();
}
Output:
Enter lenth of a side : 5
The area of squar = 25 sq. unit

No comments:

Post a Comment