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

#13 Mers

Mers

    CC Newcomer

  • Just Joined
  • PipPip
  • 11 posts

Posted 10 October 2008 - 06:54 AM

Hey,

I also got that task but I have to do it with 3 numbers.
I tried to think about a method to make it work with for loop but I couldn't find how...

I made it that way:
PROGRAM HighestNumber;
USES wincrt;
VAR
x,y,z:integer;
BEGIN
 writeln('Please input the three numbers');
 readln(x,y,z);
 if (x>y) AND (x>z) then
  writeln('The highest number is: ',x)
  else
   if (y>x) AND (y>z) then
    writeln('The highest number is: ',y)
  else
   if(z>x) AND (z>y) then
    writeln('The highest number is: ',z)
  else
   if (x=y) AND (x<>z) then
    writeln('The highest number is: ',x)
  else
   if (y=z) AND (y<>x) then
    writeln('The highest number is :',y)
  else 
   if (z=x) AND (z<>y) then
    writeln('The highest number is: ',z)
   else  
    writeln('The highest number is: ',x);
END.

  • 0

#14 ooisootuck

ooisootuck

    CC Regular

  • Just Joined
  • PipPipPip
  • 29 posts

Posted 10 October 2008 - 07:06 AM

You mean you need to loop it ten times also?
  • 0

#15 Mers

Mers

    CC Newcomer

  • Just Joined
  • PipPip
  • 11 posts

Posted 10 October 2008 - 07:48 AM

No,
I meant that I'm supposed to loop my code three times.
I tried to do that and the program just writes what's in the writeln. I want it to wait for my input and then finish the loop. How do I do that?
  • 0

#16 ooisootuck

ooisootuck

    CC Regular

  • Just Joined
  • PipPipPip
  • 29 posts

Posted 10 October 2008 - 03:05 PM

PROGRAM HighestNumber;
USES wincrt;
VAR
x,y,z, [COLOR="Red"]I[/COLOR]:integer;
BEGIN
[COLOR="Red"]for I := 1 to 3 do begin[/COLOR]
 writeln('Please input the three numbers');
 readln(x,y,z);
 if (x>y) AND (x>z) then
  writeln('The highest number is: ',x)
  else
   if (y>x) AND (y>z) then
    writeln('The highest number is: ',y)
  else
   if(z>x) AND (z>y) then
    writeln('The highest number is: ',z)
  else
   if (x=y) AND (x<>z) then
    writeln('The highest number is: ',x)
  else
   if (y=z) AND (y<>x) then
    writeln('The highest number is :',y)
  else 
   if (z=x) AND (z<>y) then
    writeln('The highest number is: ',z)
   else  
    writeln('The highest number is: ',x);
[COLOR="Red"]end;[/COLOR]
END.
This should work.

Edited by WingedPanther, 11 October 2008 - 05:04 AM.
add code tags

  • 0

#17 Mers

Mers

    CC Newcomer

  • Just Joined
  • PipPip
  • 11 posts

Posted 12 October 2008 - 04:38 PM

I did that. It would loop it but write three times the writeln without letting me enter the numbers before it continues. Should I use beak loop or something? (Or i dunno I barely know what it means... im newb... :()
  • 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