CHAN Lab9
CHAN Lab9
CHAN Lab9
Instructions:
Please answer each question in this document separately.
Rename the submission file to Lab#_<lastname>. Replace # with the lab
number and <lastname> with your last name (e.g., Lab9_Almukhtar).
Include the C file header (template is below) and add your information. (5
Points)
Declare a 1-D array of size 6 and initialize its values to [6, 8, 4, 2, 7, 9]. (5
Points)
Declare an int variable named sum and prompt the user to enter the target
sum and store it in sum. (5 Points)
Print the array on the terminal. (5 Points)
Find the first pair of numbers in the array that add up to the value of sum.
And print their indexes If no pair is found, print an appropriate message. (30
Points)
Note: More than one pair might sum up to the target, but we are only interested in the first.
Array: [6, 8, 4, 2, 7, 9]
Include the C file header (template is below) and add your information. (5
Points)
Declare a 2-D array of integers with dimensions 4x4 and initialize it
with any values of your choice. (5 Points)
Print the array on the terminal. (5 Points)
Calculates the sum of the primary diagonal elements of the array (from
top left to bottom right). (15 Points)
Find the largest element in the whole array. (15 Points)
Print the sum of the diagonal elements and the largest element on the
terminal. (5 Points)
Diagonal sum: 34
Largest element in the array: 16
C File header:
/* Filename: <FileName>
* Author: <YourName>
* Description: <Description>
*/