C program to find area of rectangle - My CS Tutorial

Breaking

Programming languages full tutorial and programs, exam papers, visual basic( Vb.net ), information of new technologies and more....

Friday, June 14, 2019

C program to find area of rectangle

In this tutorial we will find the area of rectangle.
Whenever we find the area of ​​a rectangle, then we should know its length and breadth for it.

Solution


  • In this program we take three variables where lenght,breadth and area's value will be store.
  • We declared these variables in float data type.
  • Then we will enter the value of length and breadth of a rectangle.
  • We use a logic as area=len*bre 
  • When we use this statement the value of length and breadth multiplication of a rectangle will be store in area variable.
  • Then we will print the area of rectangle.

C program code

#include<stdio.h>
#include<conio.h>
void main()
{
float len;
float bre;
float area;
clrscr();

printf("\n Enter the value of length=");
scanf("%f",&len);

printf("\n Enter the value of breadth=");
scanf("%f",&bre);

area=len*bre;

printf("\n The area of rectangle is=");
printf("%f",area);
getch();
}

Output 1:



Output 2:



This program is very simple. Whenever we find the area of ​​a rectangle, then we should know its length and breadth for it.So we use these three variables as len for length, bre for breadth and area.



No comments:

Post a Comment