Question: In this assignment you will write a C program. Your program should compile correctly and produce the specified output. Please note that the computer program
In this assignment you will write a C program. Your program should compile correctly and produce the specified output. Please note that the computer program should comply with the commenting and formatting rules as has been done in class. For example, there should be a header for the whole program that gives the authors name, class name, date, and description. End braces should be commented, and there are alignment and indenting requirements as discussed.
Program #1 Given an input file (named puzzleInput.txt) with the following format
1,2,3,6,7,8,9,4,5,
5,8,4,2,3,9,7,6,1,
9,6,7,1,4,5,3,2,8,
3,7,2,4,6,1,5,8,9,
6,9,1,5,8,3,2,7,4,
4,5,8,7,9,2,6,1,3,
8,3,6,9,2,4,1,5,7,
2,1,9,8,5,7,4,3,6,
7,4,5,3,1,6,8,9,2,
A) Write a program to read the file content and: a. Compute the array dimensions (i.e. read the file and determine the number of rows and columns (N and M ) that should be used) (10 points) Assume: i) N and M are integers >=5 and <= 40 ii) N and M could be different(i.e. N!= M) b. Load the file content into a two dimensional array (i.e char input[a][b]), where each cell is a character distinct of , ,\0, or (i.e. only letters are valid) (10 points) c. Display the file/array content in the following format: (5 points)
1 2 3 6 7 8 9 4 5
5 8 4 2 3 9 7 6 1
9 6 7 1 4 5 3 2 8
3 7 2 4 6 1 5 8 9
6 9 1 5 8 3 2 7 4
4 5 8 7 9 2 6 1 3
8 3 6 9 2 4 1 5 7
2 1 9 8 5 7 4 3 6
7 4 5 3 1 6 8 9 2
B) Ask the user for a number sequence and determine whether the sequence was found or not
a. The length of the sequence should be <= max(N,M). For example, if N=10 and M =15, the sequence cannot be longer than 15. (5 points)
b. All sequences should be >= 2 (5 points)
c. If the sequence is longer than the largest dimension, or smaller than 2, display an error message and ask the user to enter a different sequence. (5 points)
d. Determine if the sequence was found or not: (50 points)
i) Print a message like The sequence %s was not found!
or ii) The sequence %s was not found, and display the coordinates of each element, i.e. if the sequence entered was 892, then the program should display 8 Was found at (4,4) 9 Was found at (5,4) 2 Was found at (6,4) Assume that valid sequences are:
1) Left to right,
2) Right to left,
3) Top to bottom,
4) Bottom to top
Consider: The program should always display a menu.
a. Enter file location(fullpath)
b. Display the puzzle
c. Enter a sequence to find
d. Exit The file location is an input parameter (fullpath is required)
If options b or c are chosen, before option a, the program should display an error After a sequence is entered, and determined if found, the menu should be displayed again The program should terminate only when option d is chosen You should implement your own string functions (use of string.h or any other c-string header files is not allowed)
Structures can be used to store the sequence and its coordinates.
Deliverables
You will turn in two files, a Text file and a C source code file. The text file should contain:
1) Instructions to compile and use your program 2) Using the example above, whether it could find or not the following words: (10 points)
a. 69158327
b. 34689251
c. 35178264
d. 34758912
e. 2198574362
The C source code file should:
1) Comply with all of the formatting requirements already discussed. 2) Display the output
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
