You need to look at the code posted in post#19 and make sure it does what is needed to solve the problem.
This line says that the variable that holds the second largest number is never assigned...
Type: Posts; User: Norm
You need to look at the code posted in post#19 and make sure it does what is needed to solve the problem.
This line says that the variable that holds the second largest number is never assigned...
Does the program work correctly now? If not please explain what the problems are.
Where are they assigned a value? Where is the statement that starts with: max =
or with: nextmax =
What is the name of the variable you are talking about that has the value of 0?
Where is that variable assigned a value (other than 0)?
Is a value ever assigned to the variable that is printed as 0?
If the variable definitions are inside the loop, then all previous saved data is lost every time the loop goes around. There isn't enough code posted to see what it does.
Does the code compile...
OK except for count being used twice (vs nxMcount).
Now write down the logic needed to do that
and then write the code for it.
Do you need separate counters, one each for max and nextMax?
Look at what variables are needed for the task. You seem to have a few extra that are not used or are mis-used.
What about the...
There needs to be more complicated logic used that uses multiple if statements and nested if statements.
Pseudo code:
initialize
begin loop
get number
is number > max
... more logic here
else...
Use if statements to compare the various variables' values.
The posted code needs proper formatting. Nested statements should be indented 3-4 spaces
Define two variables: largest and nextLargest and save the appropriate values in each as the values are read in and compared to what was found previously.