Loop help

okay so i have a question in the test and this is a picture of it : http://prntscr.com/ip3z7n

so i try to switch from while loop to for loop and this is what i done :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
using namespace std;
int main ()
{
	int grade, counter=0;
	for(int counter=0;counter<10;counter++)
	{
		cout<<"Enter the Grade: ";
		cin>>grade;
		if(grade>60)
		cout<<"Passed \n";
		else
		cout<<"Failed \n";
		
		
	}
	return 0;
}
Last edited on
why not post your code here ?
Like this?
so what is it exactly that you need help with??
I am highly confident you figured it out; however, just in case...
On line 5,
Delete the counter variable; this variable is for the for loop, which you have it already.
For instance, line 15 should look something like:
int grade = 0;

On line 10, based on the picture you posted, it should look something like:
if (grade >= 60)

It should something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
using namespace std;
int main()
{
	int grade = 0;
	for (int counter = 0; counter < 10; counter++)
	{
		cout << "Enter the Grade: ";
		cin >> grade;
		if (grade >= 60)
			cout << "Passed \n";
		else
			cout << "Failed \n";


	}
	return 0;
}
Topic archived. No new replies allowed.