Write a program that will obtain the length and width of a rectangle from
the user and compute its area and perimeter.
#include<stdio.h>
void main()
{
float length,width,area,perimeter;
printf("Enter the length and width of a rectangle\n\n");
scanf("%f %f",&length,&width);
area=length*width;
perimeter=2*(length+width);
printf("Area of rectangle=%5.2f\nPerimeter of rectangle=%5.2f",area,perimeter);
getch();
}
the user and compute its area and perimeter.
#include<stdio.h>
void main()
{
float length,width,area,perimeter;
printf("Enter the length and width of a rectangle\n\n");
scanf("%f %f",&length,&width);
area=length*width;
perimeter=2*(length+width);
printf("Area of rectangle=%5.2f\nPerimeter of rectangle=%5.2f",area,perimeter);
getch();
}
No comments:
Post a Comment