Answer to Question #3349 in C++ for mukunda

Question #3349
Write a program to calculate the average marks of a student (Declare variables as global)?
1
Expert's answer
2011-07-19T06:22:30-0400
#include <iostream>
using namespace std;

int marks[] = { 68, 34, 56, 80 };
const int marks_size = sizeof(marks) / sizeof(int);

int main()
{
double sum = 0;
for (int i = 0; i < marks_size; ++i)
& sum += marks[i];
double average = sum / marks_size;

cout << "Average mark is " << average << endl;

return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS