Articles

C++ Qustion : use While statement

November 11, 2012 at 10:08:43
Specs: Windows 7

the quetion said :
Write a pesudocode to find the average of the students grade for ten subjects in the class
HINT: use while statement

okay i answered this question like this :


#include <iostream>
using namespace std;
int main ()
{
int total = 0 , gradecounter = 1 , grade ;
while (gradecounter <= 10)
{
cout<<"Enter grade";
cin>>grade;
total= total + grade;
gradecounter++;
}
cout<<total / 10;

system ("Pause");
return 0;
}


BUT the problem is that the output not right !!

please help me guys i have evaluation tommorrow !!


See More: C++ Qustion : use While statement

Report •


#1
November 11, 2012 at 10:14:30

1. That is not pseudocode.

2. What input did you give? What output did you expect? What output did you get?


Report •

#2
November 11, 2012 at 10:28:57

okay i will make this clear to you ( ijack)
see the number 1 ignore it okay..
number 2 : the input is there in the question , the output i get, i feel is wrong because it is Repeated ..

so i hope its clear to you now
:)


Report •

#3
November 11, 2012 at 10:35:27

I think you misunderstand. You don't show what numbers you entered and what number was printed as the result. In what way was it wrong? Are you saying that whatever was printed was printed more than once? Just looking at the code that doesn't make sense.

You need to show us exactly what you entered and what was printed.


Report •

Related Solutions

#4
November 11, 2012 at 10:55:00

they give the pseudocode , and it answered like that:

set total to zero
set grade counter to one
while grade counter is less than or equal to ten
input the next grade
add the grade into the total
add one to the grade counter
set the class average to the total divided by ten
print the class average

hope it is clear now ;p


Report •

#5
November 11, 2012 at 11:02:19

There's a lack of communication here, and I don't have the time to pursue it further. Perhaps someone else will have more patience.

Report •

#6
November 11, 2012 at 11:14:54

okay no problems :)

Report •

#7
November 11, 2012 at 12:11:30

ArwaMohammed: BUT the problem is that the output not right !!
What is the output you're getting?
What is the output you're expecting?

How To Ask Questions The Smart Way


Report •

#8
November 11, 2012 at 12:32:57

in output i get ( Enter grade ) but it was printed more than one !!

but i expect that the answer will be different ..


Report •

#9
November 11, 2012 at 12:58:06

in output i get ( Enter grade ) but it was printed more than one !!
Then move that line out of the loop.

How To Ask Questions The Smart Way


Report •

#10
November 11, 2012 at 13:03:08

Then move that line out of the loop.
which line you mean ?

Report •

#11
November 11, 2012 at 14:22:20

Mmm. That's the real question, ain't it? Don't loose heart; it should be easy for you to answer, because you wrote this, right?

How To Ask Questions The Smart Way


Report •

#12
November 11, 2012 at 14:32:26

hhhhhhhhhh you make me laugh my friend ...... i really dont know what are you talking about ;P ..... PLEASE help me i want an answer .... the time in my country is too late , i want to sleep Hhhhh .... tommorrow i have an evaluation ... >.< !!

Report •

#13
November 11, 2012 at 14:53:40

One more try.

You want the prompt to be printed more than once; once for each of the ten grades that you want to enter. So, again, what is your problem?


Report •


Ask Question