CAN'T FIND WHAT'S WRONG...
I have been programming and trying to fix a problem here but I can't find a bug. Could you guys help me advice what did I code wrong in this program? It will be thankful :)
This is what complier said after I complied the program:
In function 'main':
Line 40: error: invalid lvalue in assignment
which is:
/*Calculate area for single room*/
width * length = totalArea_single;
And here's the whole code:
#include <stdio.h>
#include <stdlib.h>
/*Main function of this program*/
int main()
{
char input[512];/*buffer*/
char roomInput[512];/*buffer*/
int roomCount =0;/*Store number of room*/
int width =0;/*width integer*/
int length =0;/*length integer*/
int room =0;/*To make sure roomCount have to be more than 0*/
int totalArea_single =0;
int totalArea_all =0;
/*Ask how many room in the house*/
printf("\nHow many rooms in the house?: ");
fgets(input,sizeof(input),stdin);
sscanf(input,"%d",&roomCount);
/*For loop for calculating room area by number of room entered*/
for(room=0;room<roomCount;room++)
{
/*Input for width and have to be more than 0*/
while(width>0)
{
printf("Width in meters for room %d: ",room+1);
fgets(roomInput,sizeof(roomInput),stdin);
sscanf(roomInput,"%d",&width);
}
/*Input for length and have to be more than 0*/
while(length>0)
{
printf("Length in meters for room %d: ",room+1);
fgets(roomInput,sizeof(roomInput),stdin);
sscanf(roomInput,"%d",&length);
}
/*Calculate area for single room*/
width * length = totalArea_single;
/*Store area of all rooms*/
totalArea_all = totalArea_single + totalArea_all;
width = -1;
length = -1;
}
/*Print out total areas of the house*/
printf("\nTotal areas of the house is %d square meters",totalArea_all);
return 0;
}
I'm not sure what did I do wrong... Thanks for your help :)