Question #43451

To enter length and breadth of rectangle and display area, perimeter and diagonal

Expert's answer

`/* Answer on Question#43451- Subject - Programming, C++ */`

#include <stdio.h>

#include <stdlib.h>

#include <math.h>

int main() /* main function*/

{

int l,b,p; /* length, breadth, perimeter */

double d; /* diagonal */

printf("Enter length: "); /* user's input */

scanf("%d",&l);

printf("Enter breadth: ");

scanf("%d",&b);

d = sqrt(pow(l,2) + pow(b,2)); /* calculate diagonal using Pifagor theorem */

p = l*2 + b*2; /* perimeter */

printf("Perimetr: %d, Diagonal: %f\n", p, d); /* prints perimeter and diagonal */

system("pause");

return 0;

}

## Comments

## Leave a comment