Could you tell me how can I do this question?

Thread Solved
Reply

Join Date: Feb 2009
Posts: 93
Reputation: turbomen is an unknown quantity at this point 
Solved Threads: 0
turbomen turbomen is offline Offline
Junior Poster in Training

Could you tell me how can I do this question?

 
0
  #1
Jul 6th, 2009
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,
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 443
Reputation: FlamingClaw will become famous soon enough FlamingClaw will become famous soon enough 
Solved Threads: 106
FlamingClaw's Avatar
FlamingClaw FlamingClaw is offline Offline
Posting Pro in Training

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

 
0
  #2
Jul 6th, 2009
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 ....
Be a good part of the community.Don't be ungrateful.
If you ask something on the forum and you got the right answer then mark as solved!
If my opinion helped to you a lot then sometimes give reputation point to me.
I'm just a pascal programmer from Hungary.
Farewell...
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 443
Reputation: FlamingClaw will become famous soon enough FlamingClaw will become famous soon enough 
Solved Threads: 106
FlamingClaw's Avatar
FlamingClaw FlamingClaw is offline Offline
Posting Pro in Training

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

 
0
  #3
Jul 6th, 2009
  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.}
Be a good part of the community.Don't be ungrateful.
If you ask something on the forum and you got the right answer then mark as solved!
If my opinion helped to you a lot then sometimes give reputation point to me.
I'm just a pascal programmer from Hungary.
Farewell...
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 93
Reputation: turbomen is an unknown quantity at this point 
Solved Threads: 0
turbomen turbomen is offline Offline
Junior Poster in Training

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

 
0
  #4
Jul 6th, 2009
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,
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 443
Reputation: FlamingClaw will become famous soon enough FlamingClaw will become famous soon enough 
Solved Threads: 106
FlamingClaw's Avatar
FlamingClaw FlamingClaw is offline Offline
Posting Pro in Training

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

 
0
  #5
Jul 6th, 2009
  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}
Be a good part of the community.Don't be ungrateful.
If you ask something on the forum and you got the right answer then mark as solved!
If my opinion helped to you a lot then sometimes give reputation point to me.
I'm just a pascal programmer from Hungary.
Farewell...
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Pascal and Delphi Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC