Write a C Program to Display the Area and Perimeter of the Rectangle

In this tutorial learn how you can display the area and perimeter of the rectangle in cIn this program, we get the inputs from the user. The inputs are the length and breadth of the rectangle. Then display the area and perimeter of the rectangle.

C programming is a powerful general-purpose programming language. It can be used to develop software like operating systems, databases, compilers, etc.

Write a C Program to Display the Area and Perimeter of the Rectangle




Write a Program to display the Area and Perimeter of the Rectangle in C

Here is the code to display the area and perimeter of the rectangle in c programming.

#include <stdio.h> //WAP to get the inputs from user. The inputs are length and breadth of rectangle. Then display the area and perimeter of the rectangle.
int main(){
    int length,breadth,area,perimeter;
    printf("Please enter the length of rectangle:");
    scanf("%d",&length); //Get length from User
    printf("Please enter the breadth of rectangle:");
    scanf("%d",&breadth); //Get breadth from User
    area = length * breadth;
    perimeter = 2*(length+breadth);
    printf("The area of rectangele is:%d\n",area); //Displays area of the rectangle
    printf("The perimeter of rectangele is:%d",perimeter); //Displays area of the rectangle

return 0;
}

Test Live At Jdoodle



Conclusion

This is how you can display the area and perimeter of the rectangle in c programming. Comment below if you like our tutorial.

0 Comments

Newest