Date: May 14, 2025
Points: 100
All programs are to be submitted through Gradescope. Gradescope will compile and execute your program, sometimes with varying inputs or invocations. You can see your score once executions are done. You can submit your program multiple times, up to the deadline — at that point, the score you have will usually be the grade for that problem. I say “usually” because we reserve the right to look at your submission and deduct points if you do not use proper programming style.
You have to name your program as given in the problem. Otherwise you will get an odd error message indicating there is a problem with Gradescope.
Also, your output must match Gradescope’s exactly, including blanks and tabs — so pay attention to the example output!
Your program first prompts for, and reads, two integers separated by blanks or tabs between 1 and 3 inclusive; if either is not, print an error message giving both numbers and stating it is not a valid square and prompt for two numbers again. If you encounter an end-of-file, end the program. For example:
> 2 4 2,4 is not a valid square; the numbers must be between 1 and 3 inclusive > 2,4 Illegal character in input "," >When an error in input occurs, print the error message on the standard error (stderrr) and ask for input again.
The upper left square has co-ordinates (1, 1) and the lower right corner has coordinates (3,3).
The two numbers are co-ordinates of the move. The first move puts an “X” in the identified square. Your program then prompts again, and this time it puts an “O in the identified square. This continues, alternating between “X”s and “O”, until either the board is full or an EOF is encountered. When either of these cases occur, exit the program with an exit status code of 0.
Your prompts reflect whether the turn is for “X” or for “O”. When it is “X”s turn, the prompt is
X's turn >␣(note the space after “>”), and when it is “O”s turn, the prompt is
O's turn >␣(again, note the space after “>”).
Here is an example input and output; the input is in \textcolor{red}{red} and the output in black.
X's turn > 1 1 # # X X # # X X # # X # # X X # # X X # # # # ####################### # # # # # # # # # # # # # # ####################### # # # # # # # # # # # # # # O's turn > 2 2 # # X X # # X X # # X # # X X # # X X # # # # ####################### # # # OOOOO # # O O # # O O # # O O # # OOOOO # # # ####################### # # # # # # # # # # # # # # X's turn > 4 2 4,2 is not a valid square; the numbers must be between 1 and 3 inclusive X's turn >Call your program toe.c. You can find an executable for it in the directory /home/bishop/hw3.
Write a program to load the contents of the file into an array, and then print out the array.The program is to take 1 argument on the command line, which is the name of the file containing the input lines.
When you print them, print the weight as a floating point number and the symbol and name as strings. The three fields are separated by tabs. You can use this string as the format for printing: “%6.2f\t%s\t%s\n”.
If you encounter one of the following errors, here’s what you do:
Call your program atomic.c You can find an executable for it, and the file atomic_weights.txt, in the directory /home/bishop/hw3.
Call your program atomicsort.c. You can find an executable for it, and the file atomic_weights.txt, in the directory /home/bishop/hw3.