Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

closed can someone help me?

+8 votes
asked Apr 19 by MIKAELA ANDREYA LACHICA (200 points)
closed May 12 by Admin

Situational Problem:

Camille has a grade in the following subject:

Araling Panlipunan (99)

Science (96)

English (90)

Filipino (91)

Math (94)

TLE (93)

What is the sum and average grade of Camille with the use of data in compiling an array?

closed with the note: answered

5 Answers

+1 vote
answered Apr 20 by Peter Minarik (53,530 points)
You can calculate the sum by adding all of those numbers (so 99 + 96 + 90 + 91 + 94 + 93 = *you do the calcualtion*).

You can calculate the average by adding all the numbers (, that is, using the sum), then dividing it by the number of elements added (in your case, that's 6).

If you store things in an array, you need to iterate through the array and take the values from the array. Then the number of elements in the array is the length of the array.

Try to write some code and share it if you get stuck. Also, include what language are you after.
+1 vote
answered Apr 20 by Kishore Kumar j s (160 points)
a = [99,96,90,91,94,93]
b = len(a)
sum1 = 0
for i in a:
    sum1 = sum1 + i
print("sum of the all subject is ",sum1)
average = sum1/b
print("average is ",average)
commented Apr 27 by ATHARV (100 points)
I think in there is correction in 5th line as
sum1=Suma+a[i]
commented May 1 by Upasana Goswami (100 points)
i want to correct one thing also in this:-
sum1=sum1+a[i]
#you wrote suma(and it will give error)
+1 vote
answered Apr 25 by userdotexe (1,190 points)
Add on the numbers together (563 in this case), then divide that by how many numbers you have (6 in this case) and you get 93.83.
+1 vote
answered Apr 27 by Павел Широков (160 points)
And here it is not required to process strings with "pulling out" numbers from brackets in order to add everything up and determine the average? Then the solution will not be so trivial.
+2 votes
answered May 12 by karimosliman (180 points)

#include <iostream>

using namespace std;

int main(){

int grades[]={99,96,90,91,94,93};

float sum=0;

for (int i=0; i<6; i++){

sum+=grades[i];

}

cout << "The sum is "<<sum<<" and the average is "<<sum/6;

return 0;

}

code made with C++ language

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...