Hi there ! Actually I am a beginner in c++ and i have a problem to convert pseudocode to c++. Hope that anyone can help me

Input : number of people, height of persons
Process: division, addition, comparison (greater than and smaller than)
Output : smallest height,
tallest height,
number of people,
average height

Algorithm : Pseudocode
Begin
Initialize counter to one
Initialize sum to zero
Prompt “Enter number of people”
Prompt “Enter height in meter: “
Assign height to smallest
Assign height to tallest
While counter less than numOfPeople do
Prompt “Enter height in meter: “
Add height to sum and assign the result to sum
Increase counter by one
If height less than smallest then
Assign height to smallest
If height greater than tallest then
Assign height to tallest
Divide sum by numOfPeople and assign the result to average
Display numOfPeople value, average value, tallest value and smallest value

End

6
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by Fbody

At least show us something you've started. You have the pseudocode there, now try and transform as much of it as you can into actual C++ code.

>> Hi there ! Actually I am a beginner in c++ and i have a problem to convert pseudocode to c++

No problem ,
How much you are a beginner?
are you just after write the ascii "hello world" program?
or do you know basic core-c++ ?

best way to do this is to go line by line and try and match pseudocode for c++ statements

for example:

you have "initialize sum to zero" ---> sum=0;

once you have the basics you need to go back and fill in the rest, try that out and then post the code so we can see how far you are.

How long will you take for this??

How long will you take for this??

I'm sure it was done the same day, or possibly the next. However, considering the fact that this thread is about 2-months old and the OP only has one (1) post, there are 3 possibilities:

1. The OP decided to solve the problem on their own (which you really should too).
2. The OP didn't get their solution and failed the assignment, maybe even their class (which you would deserve to if you are trying to cheat)
3. The OP got the solution from another site that is less concerned about helping its members learn the topic(s) well and not handing out easy 'A's.

This topic has been dead for over six months. 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.