Purpose of this assignment:
1. Gain experience with 2D arrays.
2. Learn to use strings.
Assignment:
Program #1: Write a program that prints a table of numbers with the column sums and also determines the maximum column sum.
Additional requirements:
• The table values are
5.8 8.3 9.6 3.9
4.0 7.1 11.2 2.8
-3.9 9.2 2.5 1.4
• The array values will be hard-coded into your code, but the rest of the program should be general. That is, if the array values changed, your program should work correctly for the new data. When storing the array values, you will need to at least specify the number of columns.
• To find the size of the array in a more general manner, you can use
rows = sizeof( array_name ) / sizeof( array_name[0] );
cols = sizeof( array_name[0] ) / sizeof( double );
where rows and cols are variables of type int and array name is the name of the array storing your data.
• Right-justify the values in the table.
• Your program must compile as a C89 program.
• Don't use global variables.
Sample Output: Here is some sample output to give you an idea of what you are trying to achieve.
You do not need to match this output exactly.
5.8 8.3 9.6 3.9
4.0 7.1 11.2 2.8
-3.9 9.2 2.5 1.4
=====================
5.9 24.6 23.3 8.1
The maximum column sum is 24.6
Program #2: Write a program that decrypts a secret message. The message in its encrypted form is
Tiks!ks!yhz"CTG swlfu.
On the course website is a text file that contains this message, so you don't need to cut and paste it from this PDF.
Additional requirements:
• To decrypt the message, you will change the ASCII value of the text based upon the result of dividing the array index value of the string by three:
remainder action
0 subtract 0
1 subtract 1
2 subtract 2
For example, the first character in the array has an index of 0, so 0%3 has a remainder of 0 and the character doesn't change. The second character of the array has an index of 1, so 1%3 has a remainder of 1 and you subtract 1 from the character i. Continue this process for the entire string.
• Your program must compile as a C89 program.
• Don't use global variables.