Write a C program to find area and perimeter of a rectangle given its width and height.


/* Program to find the area and perimeter of a rectangle given its width and height */

#include <stdio.h>
int main()
{
int width, length;
int area, perimeter;

width = 5; /* assign the value 5 to the variable width */
length = 7; /* assign the value 7 to the variable length */

area = width*length; /* calculate the area */
perimeter = 2*(width+length); /* calculate the perimeter */
/* Print the results */
printf("Area is %d\n", area);
printf("Perimeter is %d\n", perimeter);
return 0;
}

0 comments:

Feel free to contact the admin for any suggestions and help.