C program to find perimeter of a rectangle by length and breadth
How to find out the perimeter of rectangle whenever length and breadth you have.

Since, We know that 

            Perimeter of a rectangle =  2(length x breadth)

Logic to Solve the Problem:

1. First takes the value of length and breadth as input.

2. Apply the above formula.

3. Finally, print the value of the result of the above formula.


Example

INPUT

Enter two numbers:
length = 8
breadth = 6

OUTPUT

Perimeter of a rectangle = 2(8+6) = 28


Full Code of the finding perimeter of rectangle by its length and breadth as follows:


/*  
  * C program to enter length and breadth of a rectangle and find its perimeter.  
  */  
   
  #include<stdio.h>  
  int main()  
 {  
   int length, breadth, PeriofRect;  
    /*  
    Enter the value of length and breadth  
    */  
   printf("Enter the value of length\n");  
   scanf("%d",&length); //This takes length as input  
   
   printf("Enter the value of breadth\n");  
   scanf("%d",&breadth); //This takes breadth as input  
   /*  
   We use bracket because precedency of + is less than *.  
   */  
   PeriofRect = 2 * (length + breadth);  
   
   printf("The perimeter of rectangle having length %d and breadth %d is %d",length,breadth,PeriofRect);  
   
   return 0;  
 }  
   

Please note that we use brackets in formula. 

 PeriofRect = 2 * (length + breadth); 

Because precedency of (+) operator is less than that  of  (*) operator. So, we use brackets to make the equation performs well. As, brackets have higher precedency than any other operators.

Output
Enter the value of length
8
Enter the value of breadth
6
The perimeter of rectangle having length 8 and breadth 6 is 28



I hope you know very well how to find out the Perimeter of a Rectangle if length and breadth is given in C language. If you like this posts. Then, Please Comment Us!