Jump to content

newb pascal help...

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
16 replies to this topic

#1
raf2002

raf2002

    Newbie

  • Members
  • PipPip
  • 11 posts
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.

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
You need to use a for loop.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
raf2002

raf2002

    Newbie

  • Members
  • PipPip
  • 11 posts
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.

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
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.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
raf2002

raf2002

    Newbie

  • Members
  • PipPip
  • 11 posts
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?

#6
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
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.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#7
raf2002

raf2002

    Newbie

  • Members
  • PipPip
  • 11 posts
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.

#8
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
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;
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#9
raf2002

raf2002

    Newbie

  • Members
  • PipPip
  • 11 posts
thanks,
ill do this later and ill post if i have any problems
thanks.

#10
raf2002

raf2002

    Newbie

  • Members
  • PipPip
  • 11 posts
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:
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 them
very much appreciated!

Edited by WingedPanther, 22 September 2008 - 12:19 PM.
add code tags


#11
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
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.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#12
ooisootuck

ooisootuck

    Learning Programmer

  • Members
  • PipPipPip
  • 36 posts
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.