Computer Science, asked by 196390316017, 2 months ago

program to obtain the length and width of a rectangle from user and calculate its area, perimeter and diagonal

Answers

Answered by cslectures
3

Answer:

#include <math.h>

#include <stdio.h>

int main()

{

int width, length, area, perimeter, diagonal;

printf("Enter the length of the rectangle:\n");

scanf("%d", &length);

printf("Enter the width of the rectangle:\n");

scanf("%d", &width);

       perimeter= 2*(length + width);

printf("Perimeter of the rectangle = %d \n", perimeter);

area= length * width;

printf("Area of the rectangle = %d \n", area);

diagonal= sqrt(length*length + width*width);

printf("Diagonal of the rectangle = %d \n", diagonal);

   return 0;

}

Explanation:

Similar questions