1_ada_overview

1_ada_overview - A Simple Ada Program Introduction to...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
with ... procedure Some_Main is begin …. end Some_Main; Introduction to Computers and Programming Prof. I. K. Lundqvist Lecture 1 Mar 11 2004 A Simple Ada Program ------------------------------------- : Display Hello World on screen : Joe B : March 11, 2004 ------------------------------------- with Ada.Text_Io; use Ada.Text_Io ; procedure Hello is begin Put( "Hello World" ); end Hello; Typical Errors General Structure with . .. with . .. with . .. Ada Library with . .. Ada Library with ... procedure Some_Main is begin …. end Some_Main; -- Program Name: Hello -- Purpose -- Programmer -- Date • Compilation errors –Syntax –Semant ics • Run-time errors – Exception • Logic or Algorithm errors
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
with Fact; procedure Main is procedure Hello is begin Ada.Text_Io.Put(“Hello”); end Hello; begin for I in 1 . . Fact (4) loop Hello; end loop; end Main; function Fact (N : Integer) return Integer is begin if N <= 1 then return 1; else return N * Fact (N-1); end if; end Fact; Visibility Rules determine which declarations are visible and directly visible at each place within a program. and implicit declarations immediate use-visibility with Fact; Main is Hello is begin Ada.Text_Io.Put(“Hello”); end Hello; begin for I in 1 . . Fact (4) loop Hello; end loop; end Main; main.adb function Fact (N : Integer) return Integer is begin if N <= 1 return 1; return N * Fact (N-1); end if; end Fact; fact.adb For Loop •< loop_control_variable > time through the loop. •< lower_bound > •< upper_bound > The loop variable = upper bound, then the loop terminates. •< loop_body
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/28/2012 for the course AERO 16.01 taught by Professor Markdrela during the Fall '05 term at MIT.

Page1 / 6

1_ada_overview - A Simple Ada Program Introduction to...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online