Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  hw1
Language: PASCAL
Code:
program ch7_p225_5a;{choi hing ki 4d 08}

          var
               num : integer;
               IsArmstrong : Boolean;

          procedure CheckArmstrong(N : integer; var Armstrong : Boolean);
          var
               hunds, tens, units : integer;
          begin
               hunds := N div 100;
               tens := N mod 100 div 10;
               units := N mod 10;
               if hunds*hunds*hunds + tens*tens*tens + 
                   units*units*units = N
                    then Armstrong := TRUE
                    else Armstrong := FALSE
          end;     { CheckArmstrong }

          begin     { main program }
               write('The Armstrong numbers from 100 to 999 are: ');          
               for num := 100 to 999 do                                                  
               begin                                                                                
                    CheckArmstrong(num, IsArmstrong);                                   
                    if IsArmstrong                                                            
                         then write(num :4)                                                  
               end
          end.
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
Comments: