C++ program to find sum of marks entered by 30 students using for loop or while loop/

Recommended Answers

All 2 Replies

i am learning arrays in c++. and i think if you try for it then you can do it very easily.

as a hint
you should start loop from 0 to 29 and add values like
sum+=array[index]

if you put your efforts here it will be very easier for us to identify where you are going wrong. So , don't forget to put here your code.

// find total marks of 30 students using for loop
#include <iostream>
using namespace std;

int main()
{
    int marks[30];              
    int totalmarks = 0;         

    for(int j = 0; j < 30; j++ )
    {
        cout << "Enter marks of student " << j+1;
        cin >> marks[j];                         
        totalmarks = totalmarks + marks[j];
    }
    cout << "\nTotal marks of 30 student = " << total ;
    return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.