PLEASE HELP Write a program to calculate the area of a room
PLEASE HELP!
Write a program to calculate the area of a room by calling a function named area which you will write.
In the main function, input the floating-point length and width of the room from the keyboard.
Call the area function, passing to it the values of the length and width variables.
In the area function, calculate the area of the room and return the calculated area to the main function.
In the main function, display the length, width, and area of the room as formatted on HyperGrade.com.
Use different variable names for length and width in the main function and in the area function. Include descriptive comments in your program\'s source code. Submit your program source code to http://student.hypergrade.com.
THIS IS WHAT I GOT SO FAR
#include<stdio.h>
int main()
{
float length, width, squarefeet;
printf(\"Input the length and width of the room in feet: \ \");
scanf(\"%f %f\", &length, &width);
printf(\"The area of a room with length and width \");
squarefeet = length*width;
printf(\"%.2f\", squarefeet);
return 0;
}
HERE ARE THEIR ANSWERS:
Solution
#include <stdio.h>
float calcArea(float length,float width)
{
float area = length*width; //Here length is length of room and width is width of the room
return area; //Calculated area of the room
}
int main(void) {
// your code goes here
float length,width;
printf(\"Input the length and width of the room in feet: \ \");
scanf(\"%f\",&length);
scanf(\"%f\",&width);
float area = calcArea(length,width);
printf(\"The are of the room with length %.2f feet and width %.2f feet is %.2f squarefeet\",length,width,area);
return 0;
}

