Design a function called print_area that takes two floating-point numbers, representing the length and width of a rectangle. The print_area function calculates and prints the area of the rectangle, rounded to two decimal places.
#include<stdio.h>
//function to print area
void print_area(float length, float width){
float area = length * width;
printf("%.2f", area);
}
//Driver method
int main(){
float length, width;
printf("Enter length and width : ");
scanf("%f%f", &length, &width);
print_area(length, width);
return 0;
}
Get Answers For Free
Most questions answered within 1 hours.