# Thread: Optimizing Number of Tables in a Room

1. ## Optimizing Number of Tables in a Room

I'm trying to make a code for optimal seating arrangement to find the maximum number of people that can be seated given length and with or room, tables, and the space between each table.

How can I make my program optimize the number of tables the the room can fit, given the room's restrictions?

I'm thinking of using if and then statements, as well as greater than, less than, or greater to or equal to statements. But I dont know how to utilize them. Or if it would even be efficient to do so.

I started writing the code. But I cant even write an arithmetic operational in order to find the total number of tables a room can fit

Code:
```#studio.h

Int main( )

{
Int LengthandWidthofRoom;
Int LengthandWidthofTables;
Int PeoplePerTable;
Int SpaceBetweenTables;
Int NumberofTables;
Int TotalPeople;

LengthandWidthofRoom>=TotalNumberofTables+SpaceBetweenTables

Printf("What is the length and width of the room?" );
Scanf("%d", &LengthandWidthofRoom);

Printf("What is the length and width of each table?" );
Scanf("%d", &LengthandWidthofTables);

Printf("How many people are seated at each table?" );
Scanf("%d", PeoplePerTable);

Printf("How wide is the space between each table?" );
Scanf("%d", &SpaceBetweenTables);

TotalPeople = (PeoplePerTable*NumberofTables) + SpaceBetweenTables

return0;
}```

2. Is that pseudocode or have you been skipping class? Also, the problem description seems a bit vague. Is the description your interpretation of the description or the actual description? Are the tables meant to be square? How big are the seats?

3. Example input and associated output would be helpful.

@Hodor, I bet it was typed on an iphone!

4. Int LengthandWidthofRoom;
Int LengthandWidthofTables;
How can you declare a single variable to hold 2-Dimension (Length and Width) value?
Use two different variable to hold the value from user.
Optimizing Number of Tables in a Room
What have you tried as a solution to calculate the number of tables required or can be occupied in a room?

5. In Theory...
Code:
```#include <stdio.h>

int main(int args,char *argv[]) {

float roomWidth = 20, roomLength = 30;
float tableWidth = 4, tableLength = 7;
float spaceWidth = 4, spaceLength = 6;

float floorSpace = (roomWidth*roomLength);
float tableSize = ((tableWidth+(spaceWidth*2))*(tableLength+(spaceLength*2)));
int tableCount = (floorSpace/tableSize);

printf("In a room of size [%.2f x %.2f]. ", roomWidth,roomLength);
printf("You have a total area of [%.2f]. ", floorSpace);
printf("Considering tables that are [%.2f x %.2f], ", tableWidth,tableLength);
printf("a width spacing of [%.2f] on both sides ", spaceWidth);
printf("and a length spacing of [%.2f] on both sides. ", spaceLength);
printf("Since a table and the space around it requires [%.2f]. ",tableSize);
printf("You can fit a maximum of [%i] tables in the room. ", tableCount );
printf("\n");

return 0;
};```