Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4106
Number of posts: 14016

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Alphabetically smallest name Posted by programmer2772 on 20 May 2012 at 9:58 AM
Can somebody please look through this program and tell me why he isn't working properly. I want it to read eight names and write the alphabetically smallest one. Every helpfull advice is appriciated :)

Attachment: Alphabetise.pas (347 Bytes | downloaded 44 times)
Report
Re: Alphabetically smallest name Posted by Actor21 on 20 May 2012 at 10:51 PM
type
   stringarray = array[1 .. 8] of string ;

   function alphabetise (a : stringarray) : string ;

   var
      i, min   : integer ;
   begin
      min := 1 ;
      for i := 1 to 8 do
         if a[i] < a[min] then
            min := i ;
      alphabetise := a[min] ;
   end ;

var
   b : stringarray ;
   i : integer ;
begin
   for i := 1 to 8 do
      readln (b[i]) ;
   writeln ;
   writeln (alphabetise(b)) ;
   readln
end.





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.