make a program in c language

how to determine a number in an array in a c language

You access the index that contains the value you want. Remember that all arrays start with an index of 0.

double testResults[5] = { 89.5, 93, 90, 72.4, 89};

double total = 0;
for (int i = 0; i < 4; i++) {
	total += testResults[i];
}
double grade = total / 5;

std::cout << "Your grade for this semester is " << grade << std::endl;

Notice how the array size is 5, but the for loop only iterates up to 4.

1 Like