943,769 Members | Top Members by Rank

Ad:
Jul 6th, 2009
0

Could you tell me how can I do this question?

Expand Post »
Dear Sir,

Could you tell me how can I do this question?

Write a program that will readin three numbers nd output a message indicating whether or not the numbers were entered in ascending numerical order. (Equal entries are regarded as being in order, e.g. 4 4 5 is OK).

Cheers,
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster
turbomen is offline Offline
113 posts
since Feb 2009
Jul 6th, 2009
0

Re: Could you tell me how can I do this question?

First let's see the algorithm....
We need 3 variables for the 3 numbers,right?
We have to check the numbers one by one to see what is bigger or smaller...
And then,alert the user ....
Reputation Points: 132
Solved Threads: 138
Posting Pro
FlamingClaw is offline Offline
559 posts
since Feb 2009
Jul 6th, 2009
0

Re: Could you tell me how can I do this question?

Delphi Syntax (Toggle Plain Text)
  1. Program orders;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. Uses
  6. SysUtils;
  7. Var a,b,c:Integer;
  8. Begin
  9. Write('a: '); {1.number}
  10. ReadLn(a);
  11. Write('b: '); {2.number}
  12. ReadLn(b);
  13. Write('c: '); {3.number}
  14. ReadLn(c);
  15. {check the numbers}
  16. If (a <= b) And (a < c) And (b <= c) Then WriteLn('Good Order!')
  17. Else WriteLn('Wrong Order!');
  18. ReadLn;
  19. End.
  20. {Created by FlamingClaw 2009.06.06.}
Reputation Points: 132
Solved Threads: 138
Posting Pro
FlamingClaw is offline Offline
559 posts
since Feb 2009
Jul 6th, 2009
0

Re: Could you tell me how can I do this question?

Thank you for your help and I was misunderstanding the question in before. I thought it ask me to swap the numbers if they are not in ascending numerical order.

Cheers,
Reputation Points: 10
Solved Threads: 0
Junior Poster
turbomen is offline Offline
113 posts
since Feb 2009
Jul 6th, 2009
0

Re: Could you tell me how can I do this question?

delphi Syntax (Toggle Plain Text)
  1. {
  2. Thank you for your help and I was misunderstanding
  3. the question in before. I thought it ask me to swap
  4. the numbers if they are not in ascending numerical
  5. order.
  6. }
  7.  
  8.  
  9. Program Fixed_orders;
  10.  
  11. {$APPTYPE CONSOLE}
  12.  
  13. Uses
  14. SysUtils;
  15.  
  16. Const minimum = 1;
  17. maximum = 3;
  18.  
  19. Var MyArray:Array[minimum..maximum]Of Integer;
  20. MyI,MyK,MyT:Integer;
  21.  
  22. Begin
  23. {get the 3 numbers from the user}
  24. For MyI:=minimum To maximum Do Begin
  25. Write(MyI,'. number is: ');
  26. ReadLn(MyArray[MyI]);
  27. End;
  28.  
  29. {if needed exchange the order}
  30. For MyI:=minimum To maximum-1 Do Begin
  31. For MyK:=MyI+1 To maximum Do Begin
  32. If MyArray[MyK] < MyArray[MyI] Then Begin
  33. MyT:=MyArray[MyK];
  34. MyArray[MyK]:=MyArray[MyI];
  35. MyArray[MyI]:=MyT;
  36. End;
  37. End;
  38. End;
  39.  
  40. WriteLn;
  41. WriteLn('The results are:');
  42. {write the results}
  43. For MyI:=minimum To maximum Do Write(MyArray[MyI],',');
  44. ReadLn;
  45. End.
  46. {Created by FlamingClaw 2009.06.06}
Reputation Points: 132
Solved Threads: 138
Posting Pro
FlamingClaw is offline Offline
559 posts
since Feb 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Pascal and Delphi Forum Timeline: restricting decimal places on floating point values
Next Thread in Pascal and Delphi Forum Timeline: Please Translate C++ To Delphi





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC