Hi all,
I'm a rookie when it comes to C but I'm learning. I was wondering if someone can give me advice on my code? I'm trying to write a function that receives from the calling program the length and width of a room in decimal feet. The function should then caculate and return the number of square yards in the room.
I would like my main program to prompt for the dimensions of the room in decimal feet and the cost of a yard of carpet. Then, I would like to display both the number of yards needed and the total cost of the carpet.
I think I have my code in my function mixed up with the code in my main program. I didn't totally finish because I'm at this roadblock. Please, this is probably basic to some, but I'm just starting out. Thanks in advance for any advice. Here is my code:
Code:
#include <iostream.h>
#include <stdlib.h>
double room(double length, width, yds)
{
yds=9/(length*width);
}
return yds;
int main()
{
double length, width, cost, total;
cout<<"Enter the width of the room:";
cin>>width;
cout<<"Enter the length of the room:";
cin>>length;
cout<<"Enter the cost of a yard of carpet:";
cin>>cost;
total=room*cost;