C program to calculate area and perimeter of a Rectangle…!!!

In this tutorial we are going to write a program to calculate area and perimeter of a rectangle.Here we are going to use input and output statement for programming.

1.The main input of this program is length and breadth of the rectangle.we are going to take input from the user through scanf() statement.
2.As a processing step we need to calculate the area and perimeter of the rectangle.
3.After calculating the area and perimeter we are going to display the area and perimeter.

Hence from the above points we are going to write the program.

#include<stdio.h>
#include<conio.h>
void main()
{
  float length,breadth,area,perimeter;  //variables to store the values from the users
  clrscr();                                               //To clear the output screen
  printf("\nEnter the length of the rectangle:");
  scanf("%f",&length);
  printf("\nEnter the breadth of the rectangle:");
  scanf("%f",&breadth);
  area = length * breadth;                    //Calculating the area using the formula.
  perimeter = 2*(length + breadth);    //Calculating the perimeter using the formula.
  printf("\nArea of the rectangle with length %d and breadth %d is:%f",(int)length,(int)breadth,area);
  printf("\n\nPerimeter of the rectangle with length %d and breadth %d is:%f",(int)length,(int)breadth,perimeter);
  getch();
}

OUTPUT:
recareaperi
You can download the program:download
If you have doubts please mention them in comments

Advertisement

About Anuroop D

Very enthusiastic about technology and likes to share my knowledge through blogging. Has Bachelor's in Information Technology and currently pursuing my PhD in Computer Science.
This entry was posted in C and tagged , . Bookmark the permalink.

3 Responses to C program to calculate area and perimeter of a Rectangle…!!!

  1. sandip deshmukh says:

    thanx your program

  2. Christiana says:

    Keep Me Updated With More Feeds

  3. Rahim ullal dard says:

    Thanks help full……………!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s