Question #12965

Hi!! How can i count the total marks for my user,which they are after answering almost 20 questions?
is it any C++ coding can help me to count the marks?

Expert's answer

Here is an example of C++ program that asks for 20 numbers and counts their sum:

#include <iostream.h>

bool even(int i){
if (i%2==0) return true;
else return false;
}

int s=0, a;
int i;

void main(){
for (i=1;i<21;i++){
& cout<<"enter mark "<<i<<": ";
& cin>>a;
& s+=a;
}
cout<<"\nSum of entered numbers is "<<s<<"\n";
}

LATEST TUTORIALS
APPROVED BY CLIENTS