Can someone tell me what i'm doing wrong:

#include "stdafx.h"
#include <iostream>
#include <iomanip>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
	const int MAXGRADES = 5;
	int i, grade[MAXGRADES]= {0}, count = 0;
	double Avg, sum = 0;

	for (i=0; i < MAXGRADES; i++, count++)
		cout << "Enter a grade: ";
		cin  >> grade[i];

    if (grade[i]<0)
    cout << "This is not a correct grade";

	cout << endl;

	for (i=0; i < count; i++)
		cout << "grade " << i << " is " << grade[i] << endl;

	cout <<"\nThe sum of the grades";
	for (i=0; i < count; i++)
		cout << "  " << grade[i];
		sum = sum + grade[i];
	cout << " are " << sum << endl;

	if (count>0)
		Avg = sum / count;
	cout << endl << setw(5) << "The average is: " << Avg << endl;

	if (grade < Avg) // this line getting both errors
		cout << "*" << grade;

	return 0;
9 Years
Discussion Span
Last Post by Narue
if ( grade < Avg ) // this line getting both errors

Let's see, grade is an array of ints and Avg is a double. A guess might be that you want to iterate through the array comparing each member to Avg, but C++ won't read your mind and create that code for you.


Can someone tell me what i'm doing wrong:

Depends on what you're trying to do, what it actually does, and what it's supposed to do.

Can someone tell me what i'm doing wrong:

Formatting for one.
Explaining nothing for two.
Not posting errors for three.
Read this for further help.


I have to output all the grades and have an * placed beside any grade that is less than the average. I think a for loop might work better. I came up with this but it doesn't give me any output. Suggestions as to what i'm doing wrong?

for (i=0; grade[i] < Avg; i++)
		cout << "*" << grade[i] << endl;

God, can't you stick to one forum? I hate splitting my answers between cprog and Daniweb.

Votes + Comments
I've taken to ignoring him on both forums.
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.