Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

newb pascal help...

pascal

  • Please log in to reply
16 replies to this topic

#1 raf2002

raf2002

    CC Newcomer

  • Just Joined
  • PipPip
  • 11 posts

Posted 20 September 2008 - 03:01 AM

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.
  • 0

#2 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 20 September 2008 - 05:34 AM

You need to use a for loop.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#3 raf2002

raf2002

    CC Newcomer

  • Just Joined
  • PipPip
  • 11 posts

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.
  • 0

#4 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

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.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#5 raf2002

raf2002

    CC Newcomer

  • Just Joined
  • PipPip
  • 11 posts

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?
  • 0

#6 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

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.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#7 raf2002

raf2002

    CC Newcomer

  • Just Joined
  • PipPip
  • 11 posts

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.
  • 0

#8 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

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;
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#9 raf2002

raf2002

    CC Newcomer

  • Just Joined
  • PipPip
  • 11 posts

Posted 20 September 2008 - 07:10 AM

thanks,
ill do this later and ill post if i have any problems
thanks.
  • 0

#10 raf2002

raf2002

    CC Newcomer

  • Just Joined
  • PipPip
  • 11 posts

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:
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

  • 0

#11 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

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.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#12 ooisootuck

ooisootuck

    CC Regular

  • Just Joined
  • PipPipPip
  • 29 posts

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.
  • 0





Also tagged with one or more of these keywords: pascal

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download