please write this program in C language only. Write two functions, area and peri
ID: 3651339 • Letter: P
Question
please write this program in C language only.Write two functions, area and perimeter, each receiving 2 integer
parameters, length and width (of a rectangle). As their names suggest, area should
return the rectangle area, and perimeter should return its perimeter. Write the
main program which should prompt the user for the length and width, call the
functions, and print the area and perimeter of the rectangle. A sample run is
illustrated below, with user input typed in boldface.
Rectangle Geometry
Please enter the rectangle length: 10
Please enter the rectangle width: 8
A rectangle with length 10 and width 8
has area 80 and perimeter 38.
Explanation / Answer
please rate - thanks
note: the perimeter is wrong on your post
#include<stdio.h>
#include <conio.h>
int area(int,int);
int perimeter(int,int);
int main()
{int length,width,a,p;
printf("Rectangle Geometry ");
printf("Please enter the rectangle length: ");
scanf("%d",&length);
printf("Please enter the rectangle width: ");
scanf("%d",&width);
printf("A rectangle with length %d and width %d ",length,width);
a=area(length,width);
p=perimeter(length,width);
printf("has area %d and perimeter %d. ",a,p);
getch();
return 0;
}
int area(int l,int w)
{return l*w;
}
int perimeter(int l,int w)
{return l+l+w+w;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.