Hint: Use two for loops. Second loop starts with i = NUM_VALS - 1. #include <std
ID: 644544 • Letter: H
Question
Hint: Use two for loops. Second loop starts with i = NUM_VALS - 1.
#include <stdio.h>
int main(void) {
const int NUM_VALS = 4;
int courseGrades[NUM_VALS];
int i = 0;
courseGrades[0] = 7;
courseGrades[1] = 9;
courseGrades[2] = 11;
courseGrades[3] = 10;
/* Your solution goes here */
return 0;
}
7 9 11 10 10 11 9 7
Hint: Use two for loops. Second loop starts with i = NUM_VALS - 1.
Explanation / Answer
#include <stdio.h>
int main(void) {
const int NUM_VALS = 4;
int courseGrades[NUM_VALS];
int i = 0;
courseGrades[0] = 7;
courseGrades[1] = 9;
courseGrades[2] = 11;
courseGrades[3] = 10;
for(i = 0; i < NUM_VALS; ++i){
printf("%d ", courseGrades[i]);
}
printf(" ");
for(i = NUM_VALS - 1; i >= 0; --i){
printf("%d ", courseGrades[i]);
}
printf(" ");
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.