im learning pascal at a-level and my homework is to,
when a user has entered 10 numbers on the screen, pascal should show the highest number and lowest number, like
writeln ('the highest of those 10 numbers is ' , highest number);
and for the lowest number.
thanks!
it NEEDS to have a loop, of 10.
ive done case, loops and if then else, but im stuck at this!
any help would be appreciated greatly.
thanks.
newb pascal help...
Started by raf2002, Sep 20 2008 03:01 AM
16 replies to this topic
#1
Posted 20 September 2008 - 03:01 AM
|
|
|
#2
Posted 20 September 2008 - 05:34 AM
You need to use a for loop.
#3
Posted 20 September 2008 - 06:07 AM
can u help me?
i think u telling me the whole script is too much lol.
but can you help me with the for loop...thanks.
i think u telling me the whole script is too much lol.
but can you help me with the for loop...thanks.
#4
Posted 20 September 2008 - 06:25 AM
Your question is a little vague, which is why the response is similarly vague.
I'm not sure if your issue is with the logic of the program or with how to implement the logic of the program. Can you show us what you've come up with so far?
Note: If you don't know the logic for your program, don't think about code.
I'm not sure if your issue is with the logic of the program or with how to implement the logic of the program. Can you show us what you've come up with so far?
Note: If you don't know the logic for your program, don't think about code.
#5
Posted 20 September 2008 - 06:28 AM
okay ill rephrase it,
i was told i need to make a loop program on pascal, and when ran the user will be asked to enter a number, and that question will be looped 10 times.
at the time of the 10 loop, the program will say, 'the highest number that you entered was , (highest number user entered)'.
does that make more sense?
i was told i need to make a loop program on pascal, and when ran the user will be asked to enter a number, and that question will be looped 10 times.
at the time of the 10 loop, the program will say, 'the highest number that you entered was , (highest number user entered)'.
does that make more sense?
#6
Posted 20 September 2008 - 06:32 AM
I understand the question perfectly, and can code an answer in about 2 minutes. I am trying to understand what you need help with. What part of the question are you having issues with?
Example:
Do you know how to create a for loop?
Do you know how to ask a user for input?
Do you know how to compare numbers?
Do you know how to store numbers in variables?
Do you understand the logic that will have to be implemented in code?
Can you create a flowchart of the logic?
Can you create pseudocode of the logic?
My goal is to help you think about the problem effectively so that you can solve it. I will not provide you with the solution.
Example:
Do you know how to create a for loop?
Do you know how to ask a user for input?
Do you know how to compare numbers?
Do you know how to store numbers in variables?
Do you understand the logic that will have to be implemented in code?
Can you create a flowchart of the logic?
Can you create pseudocode of the logic?
My goal is to help you think about the problem effectively so that you can solve it. I will not provide you with the solution.
#7
Posted 20 September 2008 - 06:35 AM
Do you know how to create a for loop?yes
Do you know how to ask a user for input?yes
Do you know how to compare numbers?no
Do you know how to store numbers in variables?yes
Do you understand the logic that will have to be implemented in code?no
Can you create a flowchart of the logic?no
Can you create pseudocode of the logic?no
if it takes u 2 mins, could u write it and i will understand it, thanks so far for your time.
Do you know how to ask a user for input?yes
Do you know how to compare numbers?no
Do you know how to store numbers in variables?yes
Do you understand the logic that will have to be implemented in code?no
Can you create a flowchart of the logic?no
Can you create pseudocode of the logic?no
if it takes u 2 mins, could u write it and i will understand it, thanks so far for your time.
#8
Posted 20 September 2008 - 07:04 AM
OK, the basic issue is you will need three variables: max, min, input.
For the initial input: max:=input;min:=input;
For each additional input: if max<input then max:=input; if min>input then min:=input;
For the initial input: max:=input;min:=input;
For each additional input: if max<input then max:=input; if min>input then min:=input;
#9
Posted 20 September 2008 - 07:10 AM
thanks,
ill do this later and ill post if i have any problems
thanks.
ill do this later and ill post if i have any problems
thanks.
#10
Posted 21 September 2008 - 08:56 AM
thanks i did that successfully. but now i have another issue
the question is
write a pacal program to input 10 exam marks, count and display the number of passes >=50% and other fails.
i got this so far:
very much appreciated!
the question is
write a pacal program to input 10 exam marks, count and display the number of passes >=50% and other fails.
i got this so far:
program ex31;
var
count,mark,total:integer;
begin
for count:= 1 to 10 do
begin
total:=0;
writeln('what percentage did you get?');
readln(mark);
if mark>=50 then
begin writeln('Pass');
end
else if mark<=49 then
begin writeln('fail');
end;
readln;
total:=
end;
end.
im stuck on what to write on the total! please someone write the edits and explain themvery much appreciated!
Edited by WingedPanther, 22 September 2008 - 12:19 PM.
add code tags
#11
Posted 22 September 2008 - 12:19 PM
You're not supposed to write pass/fail for each one. Just count inside the loop (with variables) and report the values of those variables outside the loop. Also, be sure to use code tags when posting code.
#12
Posted 09 October 2008 - 10:35 PM
Hi,
The program will loop 10 times, in fact you do not need the last part of the readln, it will loop back to the top of the for loop.
The program will loop 10 times, in fact you do not need the last part of the readln, it will loop back to the top of the for loop.
Patrick Ooi, http://www.webhyper.com


Sign In
Create Account


Back to top









