# Homework help - programming 101

Discussion in 'OT Technology' started by c.a, Dec 29, 2009.

1. ### c.aNew Member

Joined:
Jan 24, 2006
Messages:
1,117
0
Fisrt of all, Im not asking for someone to do my homework for me, i just need help.

Alright so I'm completely new at this stuff, and I have an assignment due tomorrow and am really lost.

I have to make a flowchart and psuedocode for a program that will take a set of numbers that the user enters and put them in an array and then display all the numbers and then the highest and lowest number.

I'm confused about how to show an array in a flowchart and how to find the highest and lowest number if I dont know how many numbers the person will be entering.

Anyone have any ideas?

Last edited: Dec 29, 2009
2. ### CodeXGuest

Output prompt
Find smallest element
Find largest element
Output array
Output smallest and largest elements

Which one of those things do you need help with?

3. ### c.aNew Member

Joined:
Jan 24, 2006
Messages:
1,117
0
I don't know how to put the input into an array or how to find the smallest or largest elements

4. ### CodeXGuest

This is pseudo code... just state that you are putting each input value into consecutive array indices.
I would write it like this:

While(!done) array[i++] = GetInputVal

But my pseudo code is always less pseudo and more code...

As far as finding the max, set a variable named max to 0, iterate through the array, checking to see if each value is greater than the current, when one is, replace the value of the max variable with that value and continue, once you reach the end of the array the max variable will hold the largest array value.

To find the min value do the opposite, set an unsigned min variable to -1 (max value) and then iterate through the array looking for smaller values, replacing the value in the min variable each time you find a smaller one.

Here is pseudo code for finding the max:

Max = 0
for each array element
{
if array element > Max then Max = array element
}