Menu

Question 5 10 Marks Oiven Following Array X Output Executing Program Segment 6 M 51 X 20 6 Q43783967

Question 5 (10 marks) a) Oiven the following array X, What is the output after executing the program segment [6 m) 5.1? X 2064 48 52 97 Figure 5: array weight iii. Declare an array of strings named friends that can store 5 names, and the maximum lenQuestion 5 (10 marks) a) Oiven the following array X, What is the output after executing the program segment [6 m) 5.1? X 20 | 60 | 100 | 140 | //program segment 5.1 int 1 – 2 x 10 = x(1) printf(“%.2fn”, x(0)); printf(“%.2fn”, *(1) +2); printf(“%.2fn”, *(1-21) printf(“%.2fn”, *(1+1), printf(“%.2fn”, x(0+2) = x(0+ x(11) printf(“%.2fn”, **%(11): b) Write the C statements to: 1. Declare and initialize array weight with values as shown in Figure 5 below. ii. Assign the last element with a new value, which is 78. [2 m) 64 48 52 97 Figure 5: array weight iii. Declare an array of strings named friends that can store 5 names, and the maximum length of characters is five (5). Initialize the array with the following names: Ann, Bill, Chad, Dave, Eddy. Print the name Dave from the array, 12 m) Show transcribed image text Question 5 (10 marks) a) Oiven the following array X, What is the output after executing the program segment [6 m) 5.1? X 20 | 60 | 100 | 140 | //program segment 5.1 int 1 – 2 x 10 = x(1) printf(“%.2fn”, x(0)); printf(“%.2fn”, *(1) +2); printf(“%.2fn”, *(1-21) printf(“%.2fn”, *(1+1), printf(“%.2fn”, x(0+2) = x(0+ x(11) printf(“%.2fn”, **%(11): b) Write the C statements to: 1. Declare and initialize array weight with values as shown in Figure 5 below. ii. Assign the last element with a new value, which is 78. [2 m)
64 48 52 97 Figure 5: array weight iii. Declare an array of strings named friends that can store 5 names, and the maximum length of characters is five (5). Initialize the array with the following names: Ann, Bill, Chad, Dave, Eddy. Print the name Dave from the array, 12 m)

Expert Answer


Answer to Question 5 (10 marks) a) Oiven the following array X, What is the output after executing the program segment [6 m) 5.1? …

OR