C Program to Calculate Area and Perimeter of Square and Rectangle

#include<stdio.h>
#include<conio.h>
void main()
{
    clrscr();
    int length, breadth,area_of_square,perimeter_of_square, perimeter_of_rectangle,area_of_rectangle,side;
    printf("\n Enter length and breadth of the rectangle :");
    scanf("\n %d%d",&length,&breadth);
    printf("\n Enter Side of Square :");
    scanf("\n %d",&side);
    area_of_rectangle=length*breadth;
    perimeter_of_rectangle=(2*length)+(2*breadth);
    area_of_square=side*side;
    perimeter_of_square=4*side;
    printf("\n Area of rectangle = %d \tPerimeter=%d",area_of_rectangle,perimeter_of_rectangle);
    printf("\n Area of square = %d \t\t Perimeter=%d",area_of_square,perimeter_of_square);
    getch();
}

Run:



No comments:

Post a Comment

100 C Programs with Code and Output

Program 1: C Program To Read Two Numbers And Print The Sum Of Given Two Numbers. Program 2: C Program To Read Three Numbers And Prin...