ok i have to make a program that asks the user to enter how many kid are in their class, the ask the score for each kid, then display how many are passing. (70/100 is passing). im not sure how to make it count how many times the number 70+ was entered. anyone know how? this is what i have so far.

#include <iostream>
using namespace std;

int kids;
int pass;
int score;

int main()
{
cout << "Enter number of students: ";
cin >> kids;

for (int count = 1; count <= kids; count++) 
{ 

cout << "What was student " << count << "s score? "; 
cin >> score; 

}

system("PAUSE");
return 0;
}

Recommended Answers

All 3 Replies

#include <iostream>

using namespace std;

int kids = 0;
int pass = 0;
int score = 0;

int main(int argc, char **argv)
{
	cout << "Enter number of students: ";
	cin >> kids;

	for (int count = 1; count <= kids; count++) {
		cout << "What was student " << count << "s score? ";
		cin >> score;
		if (score > 69) pass++;
	}

	cout << "There Are " << pass << " passing students :)" << endl;

	cin.ignore();

	return 0;
}

I hope you get a good grade on the assignment, Comatose

I hope you get a good grade on the assignment, Comatose

The poster had the assignment 90% finished, so that's showing some effort right? Comatose wasn't doing anything wrong by showing the poster how to code the last few percent IMO.
You could argue that Comatose didn't explain what he added/changed and that the OP might not have learned how to come up with this answer him(her)self, and I might even partially agree. On the other hand: the added code speaks for itself if you know how to read English.

commented: Thanks :) +10
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.