Slide: 1 Copyright © AdaCore Your First Ada Program Presented by Quentin Ochem University.adacore.com.

Slides:



Advertisements
Similar presentations
Python Basics: Statements Expressions Loops Strings Functions.
Advertisements

Slide: 1 Copyright © AdaCore Record Types Presented by Quentin Ochem university.adacore.com.
Slide: 1 Copyright © AdaCore Packages Presented by Quentin Ochem university.adacore.com.
Slide: 1 Copyright © AdaCore Arrays Presented Quentin Ochem university.adacore.com.
Slide: 1 Copyright © AdaCore Rotating Balls Presented by Quentin Ochem university.adacore.com.
What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the.
PL/SQL.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 8- 1 Overview 8.1 An Array Type for Strings 8.2 The Standard string.
Strings in C++ 04/29/11. Quiz Arrays  Section 7.1 & 7.2  Array basics  Partially filled arrays  Passing individual elements Mon. 05/02/11.
11.3 Function Prototypes A Function Prototype contains the function’s return type, name and parameter list Writing the function prototype is “declaring”
1 Lecture Today’s topic Arrays Reading for this Lecture: –Chaper 11.
Comparing Numeric Values If Val(Text1.Text) = MaxPrice Then (Is the current numeric value stored in the Text property of Text1 equal to the value stored.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 13 - The Preprocessor Outline 13.1Introduction.
1 CSE1301 Computer Programming Lecture 5: Components of a C Program (Part 1)
Chapter 7. 2 Objectives You should be able to describe: The string Class Character Manipulation Methods Exception Handling Input Data Validation Namespaces.
Introduction to Class Modules Please use speaker notes for additional information!
Chapter 5 new The Do…Loop Statement
Ada is a structured, statically typed, imperative, wide- spectrum, and object-oriented high-level computer programming language, extended from Pascal.
2440: 211 Interactive Web Programming Expressions & Operators.
Slide: 1 Copyright © AdaCore Basic Types Presented by Quentin Ochem university.adacore.com.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 5 – Dental Payment Application: Introducing.
1 CSE1301 Computer Programming Lecture 5: Components of a C Program (Part 1) Linda M c Iver.
Java 2 More Java Then Starbucks ;-). Important Terms Primitive Data – Basic, built-in values (characters & numbers) Data Type – Used to talk about values.
Slide: 1 Copyright © AdaCore Subprograms Presented by Quentin Ochem university.adacore.com.
ICAPRG301A Week 2 Strings and things Charles Babbage Developed the design for the first computer which he called a difference engine, though.
Operations on Strings. 8/8/2005 Copyright 2006, by the authors of these slides, and Ateneo de Manila University. All rights reserved L: String Manipulation.
Chap 5 Control Structure Boolean Expression and the IF Statement.
CSC1030 HANDS-ON INTRODUCTION TO JAVA Introductory Lab.
Introduction to Visual Basic Programming. Introduction Simple Program: Printing a Line of Text Another Simple Program: Adding Integers Memory Concepts.
JavaScript, Fourth Edition
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Slide: 1 Copyright © AdaCore Ten Bouncing Balls Presented by Quentin Ochem university.adacore.com.
Part:2.  Keywords are words with special meaning in JavaScript  Keyword var ◦ Used to declare the names of variables ◦ A variable is a location in the.
How the Session Works Outline Practical on arrival Talk 1 Reflect on practical Clarify concepts Practical exercises at your own pace Talk 2: Further concepts.
Midterm Review Important control structures Functions Loops Conditionals Important things to review Binary Boolean operators (and, or, not) Libraries (import.
Slide 1 Controls v Control naming convention –Label: lblName –Command Button: cmdName –Text Box: txtName.
 Variables can store data of different types, and different data types can do different things.  PHP supports the following data types:  String  Integer.
Scion Macros How to make macros for Scion The Fast and Easy Guide.
Visual Basic Review LBS 126. VB programming Project Form 1Form 2Form 3 Text boxButton Picture box Objects Text box Button Objects.
Announcements Assignment 1 due Wednesday at 11:59PM Quiz 1 on Thursday 1.
Knowledge Base. Defining a Variable Dim statement Dim intXX As Integer Public in a Module Public dblNN As Double.
Euphoria Programming Language CSC 507 Kasilingam Vimalan.
structured statically typed imperative wide-spectrum object-oriented high-level computer programming language extended from Pascal and other languages.
Chapter Four Common facilities of procedural languages.
© 2010 Lawrenceville Press Slide 1 Chapter 5 The Do…Loop Statement  Loop structure that executes a set of statements as long as a condition is true. 
Foundations of Programming: Java
Definition of the Programming Language CPRL
Chapter 6 JavaScript: Introduction to Scripting
COP2800 – Computer Programming Using JAVA
Bill Tucker Austin Community College COSC 1315
Welcome to Computer Science Jeopardy
Fundamentals of PL/SQL part 1 (Basics)
Chapter 13 - The Preprocessor
XNAT 1.7 DicomEdit 4, DicomEdit 6, and Mizer
Making Decisions in a Program
Introduction to C++ Programming
Easy Ada tooling with Libadalang Raphaël Amiard.
Easy Ada tooling with Libadalang Raphaël Amiard
Escape sequences: Practice using the escape sequences on the code below to see what happens. Try this next code to help you understand the last two sequences.
copyright © Michael B. Feldman, All Rights Reserved
Convert from Variable Character to Float
Microsoft Visual Basic 2005: Reloaded Second Edition
Intro to Programming Concepts
Python Basics with Jupyter Notebook
The structure of programming
Java Programming with BlueJ Objectives
JavaScript: Introduction to Scripting
The Selection Structure
Intro to Programming (in JavaScript)
COMPUTING.
Presentation transcript:

Slide: 1 Copyright © AdaCore Your First Ada Program Presented by Quentin Ochem University.adacore.com

Slide: 2 Copyright © AdaCore with Ada.Text_IO; procedure Hello is A, B, C : Integer; begin A := Integer'Value (Ada.Text_IO.Get_Line); B := Integer'Value (Ada.Text_IO.Get_Line); C := A + B; if C = 0 then Ada.Text_IO.Put_Line ("RESULT IS 0"); elsif C > 0 then Ada.Text_IO.Put_Line ("POSITIVE RESULT :" & Integer'Image (C)); else Ada.Text_IO.Put_Line ("NEGATIVE RESULT :" & Integer'Image (C)); end if; end Hello;

Slide: 3 Copyright © AdaCore with Ada.Text_IO; procedure Hello is A, B, C : Integer; begin A := Integer'Value (Ada.Text_IO.Get_Line); B := Integer'Value (Ada.Text_IO.Get_Line); C := A + B; if C = 0 then Ada.Text_IO.Put_Line ("RESULT IS 0"); elsif C > 0 then Ada.Text_IO.Put_Line ("POSITIVE RESULT :" & Integer'Image (C)); else Ada.Text_IO.Put_Line ("NEGATIVE RESULT :" & Integer'Image (C)); end if; end Hello; Main subprogram name (can be any Ada identifier) End of main name (optional)

Slide: 4 Copyright © AdaCore with Ada.Text_IO; procedure Hello is A, B, C : Integer; begin A := Integer'Value (Ada.Text_IO.Get_Line); B := Integer'Value (Ada.Text_IO.Get_Line); C := A + B; if C = 0 then Ada.Text_IO.Put_Line ("RESULT IS 0"); elsif C > 0 then Ada.Text_IO.Put_Line ("POSITIVE RESULT :" & Integer'Image (C)); else Ada.Text_IO.Put_Line ("NEGATIVE RESULT :" & Integer'Image (C)); end if; end Hello; Variables declaration, only before begin

Slide: 5 Copyright © AdaCore with Ada.Text_IO; procedure Hello is A, B, C : Integer; begin A := Integer'Value (Ada.Text_IO.Get_Line); B := Integer'Value (Ada.Text_IO.Get_Line); C := A + B; if C = 0 then Ada.Text_IO.Put_Line ("RESULT IS 0"); elsif C > 0 then Ada.Text_IO.Put_Line ("POSITIVE RESULT :" & Integer'Image (C)); else Ada.Text_IO.Put_Line ("NEGATIVE RESULT :" & Integer'Image (C)); end if; end Hello; Statements, only between begin … end

Slide: 6 Copyright © AdaCore with Ada.Text_IO; procedure Hello is A, B, C : Integer; begin A := Integer'Value (Ada.Text_IO.Get_Line); B := Integer'Value (Ada.Text_IO.Get_Line); C := A + B; if C = 0 then Ada.Text_IO.Put_Line ("RESULT IS 0"); elsif C > 0 then Ada.Text_IO.Put_Line ("POSITIVE RESULT :" & Integer'Image (C)); else Ada.Text_IO.Put_Line ("NEGATIVE RESULT :" & Integer'Image (C)); end if; end Hello; The Ada assignment is := The Ada equality operator is =

Slide: 7 Copyright © AdaCore with Ada.Text_IO; procedure Hello is A, B, C : Integer; begin A := Integer'Value (Ada.Text_IO.Get_Line); B := Integer'Value (Ada.Text_IO.Get_Line); C := A + B; if C = 0 then Ada.Text_IO.Put_Line ("RESULT IS 0"); elsif C > 0 then Ada.Text_IO.Put_Line ("POSITIVE RESULT :" & Integer'Image (C)); else Ada.Text_IO.Put_Line ("NEGATIVE RESULT :" & Integer'Image (C)); end if; end Hello; ' introduces a special property, called attribute

Slide: 8 Copyright © AdaCore with Ada.Text_IO; procedure Hello is A, B, C : Integer; begin A := Integer'Value (Ada.Text_IO.Get_Line); B := Integer'Value (Ada.Text_IO.Get_Line); C := A + B; if C = 0 then Ada.Text_IO.Put_Line ("RESULT IS 0"); elsif C > 0 then Ada.Text_IO.Put_Line ("POSITIVE RESULT :" & Integer'Image (C)); else Ada.Text_IO.Put_Line ("NEGATIVE RESULT :" & Integer'Image (C)); end if; end Hello; Value is an attribute transforming a String to a value of a type Image is an attribute transforming a value of a type to a String

Slide: 9 Copyright © AdaCore with Ada.Text_IO; procedure Hello is A, B, C : Integer; begin A := Integer'Value (Ada.Text_IO.Get_Line); B := Integer'Value (Ada.Text_IO.Get_Line); C := A + B; if C = 0 then Ada.Text_IO.Put_Line ("RESULT IS 0"); elsif C > 0 then Ada.Text_IO.Put_Line ("POSITIVE RESULT :" & Integer'Image (C)); else Ada.Text_IO.Put_Line ("NEGATIVE RESULT :" & Integer'Image (C)); end if; end Hello; with allow to use a library unit, here Ada.Text_IO for textual functions

Slide: 10 Copyright © AdaCore with Ada.Text_IO; procedure Hello is A, B, C : Integer; begin A := Integer'Value (Ada.Text_IO.Get_Line); B := Integer'Value (Ada.Text_IO.Get_Line); C := A + B; if C = 0 then Ada.Text_IO.Put_Line ("RESULT IS 0"); elsif C > 0 then Ada.Text_IO.Put_Line ("POSITIVE RESULT :" & Integer'Image (C)); else Ada.Text_IO.Put_Line ("NEGATIVE RESULT :" & Integer'Image (C)); end if; end Hello; Get_Line reads a line on the command line Put_Line prints text on the command line

Slide: 11 Copyright © AdaCore with Ada.Text_IO; procedure Hello is A, B, C : Integer; begin A := Integer'Value (Ada.Text_IO.Get_Line); B := Integer'Value (Ada.Text_IO.Get_Line); C := A + B; if C = 0 then Ada.Text_IO.Put_Line ("RESULT IS 0"); elsif C > 0 then Ada.Text_IO.Put_Line ("POSITIVE RESULT :" & Integer'Image (C)); else Ada.Text_IO.Put_Line ("NEGATIVE RESULT :" & Integer'Image (C)); end if; end Hello; & is the concatenation operator, used between String

Slide: 12 Copyright © AdaCore with Ada.Text_IO; procedure Hello is A, B, C : Integer; begin A := Integer'Value (Ada.Text_IO.Get_Line); B := Integer'Value (Ada.Text_IO.Get_Line); C := A + B; if C = 0 then Ada.Text_IO.Put_Line ("RESULT IS 0"); elsif C > 0 then Ada.Text_IO.Put_Line ("POSITIVE RESULT :" & Integer'Image (C)); else Ada.Text_IO.Put_Line ("NEGATIVE RESULT :" & Integer'Image (C)); end if; end Hello; elsif introduces an alternative decision if … then delimitates a decision, no need for parenthesis

Slide: 13 Copyright © AdaCore Quiz

Slide: 14 Copyright © AdaCore Identify the Errors with Ada.Text_IO; procedure Hello is A, B : Integer; A = Integer'Image (Ada.Text_IO.Get_Line); B = Integer'Image (Ada.Text_IO.Get_Line); if A == B then Ada.Text_IO.Put_Line ("A EQUALS B, VALUE IS " & A); end if; end Hello;

Slide: 15 Copyright © AdaCore with Ada.Text_IO; procedure Hello is A, B : Integer; A = Integer'Image (Ada.Text_IO.Get_Line); B = Integer'Image (Ada.Text_IO.Get_Line); if A == B then Ada.Text_IO.Put_Line ("A EQUALS B, VALUE IS " & A); end if; end Hello;

Slide: 16 Copyright © AdaCore with Ada.Text_IO; procedure Hello is A, B : Integer; A = Integer'Image (Ada.Text_IO.Get_Line); B = Integer'Image (Ada.Text_IO.Get_Line); if A == B then Ada.Text_IO.Put_Line ("A EQUALS B, VALUE IS " & A); end if; end Hello; “begin” is needed to introduce a sequence of statements

Slide: 17 Copyright © AdaCore with Ada.Text_IO; procedure Hello is A, B : Integer; begin A = Integer'Image (Ada.Text_IO.Get_Line); B = Integer'Image (Ada.Text_IO.Get_Line); if A == B then Ada.Text_IO.Put_Line ("A EQUALS B, VALUE IS " & A); end if; end Hello; The Ada assignment instruction is :=

Slide: 18 Copyright © AdaCore with Ada.Text_IO; procedure Hello is A, B : Integer; begin A := Integer'Image (Ada.Text_IO.Get_Line); B := Integer'Image (Ada.Text_IO.Get_Line); if A == B then Ada.Text_IO.Put_Line ("A EQUALS B, VALUE IS " & A); end if; end Hello; Image converts a number into a string, Value would convert a string to a number

Slide: 19 Copyright © AdaCore with Ada.Text_IO; procedure Hello is A, B : Integer; begin A := Integer'Value (Ada.Text_IO.Get_Line); B := Integer'Value (Ada.Text_IO.Get_Line); if A == B then Ada.Text_IO.Put_Line ("A EQUALS B, VALUE IS " & A); end if; end Hello; The Ada equality operator is =

Slide: 20 Copyright © AdaCore with Ada.Text_IO; procedure Hello is A, B : Integer; begin A := Integer'Value (Ada.Text_IO.Get_Line); B := Integer'Value (Ada.Text_IO.Get_Line); if A = B then Ada.Text_IO.Put_Line ("A EQUALS B, VALUE IS " & A); end if; end Hello; A is not a String, need to be converted through Integer’Image (A)

Slide: 21 Copyright © AdaCore with Ada.Text_IO; procedure Hello is A, B : Integer; begin A := Integer'Value (Ada.Text_IO.Get_Line); B := Integer'Value (Ada.Text_IO.Get_Line); if A = B then Ada.Text_IO.Put_Line ("A EQUALS B, VALUE IS " & Integer'Image (A)); end if; end Hello;

Slide: 22 Copyright © AdaCore university.adacore.com