Hi, can anyone help me with my coding? I am a beginner and I want to practice a lot but I have a limitation of knowledge about c programming. My coding must consist of
1. a seat available, if user choose unavailable seat(the one with x mark), it will display "seat unavailable, Please choose another seat"
2. when a user enters 5 persons, then they can choose 5 seats(this one I do not know how to do it)
3. display what seat they choose.
I’d like to express my deepest appreciation for your guidance. You not only realized my mistake, but you also turned every mistake into a learning opportunity. Your guidance has been influential, and I know it will shape my developing skills. I'm sorry for the mistakes I made :) and thank you again for your reply.
You haven't answered Handy Andy's question about whether this is supposed to be a C or a C++ program.
Lines 13: You input p. Line 17: You overwrite p with the uninitialized values of k.
Line 17: You probably don't want to use a floating point format descriptor to input an integer. n It's not likely you're going to have a fractional number of passengers.
Line 19: You loop an indeterminate number of times. Your upper loop limit (k) is still uninitialized.
Line 21: You're giving the example of 6F, which is a row an column, but you scanf statement at line 22 is accepting only a single character.
Lines 30-37: You're printing a fixed seat map. You want to keep the seat map in a 2D array so that when you make a change, that change is reflected in the array and print out that array.
The question I have been waiting on an answer for is. Should this be a C program or a C++ program?. I do not know which direction to go with the code.
This does not matter whether it is a C or C++ program the use of "\t" can be a problem. Given a line in the "Seat" function printf("1 \t*\t*\t*\t*\t*\t*\t*\n"); and saying that the output is different,the (1) being something with more characters, the following "\t" may not create the proper spacing and could make the rest of the line not line up in the same place as the rest of the output.
Sometimes it is easier to just use a space over using a "\t". C++ has a function that can be used to space out what you want should you need a C++ program.
In a program one thing I have see most often is that a 2D "char" array is used to keep track of which seats are empty and which ones are taken.