Translating Pseudocode into computer languages Lecture 14.

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

Chapter 6 Type Checking. The compiler should report an error if an operator is applied to an incompatible operand. Type checking can be performed without.
Programming Languages and Paradigms The C Programming Language.
Chapter 41 Variables and JSP Control Structures JavaServer Pages By Xue Bai.
Lecture # 21 Chapter 6 Uptill 6.4. Type System A type system is a collection of rules for assigning type expressions to the various parts of the program.
Expressions and Statements. 2 Contents Side effects: expressions and statements Expression notations Expression evaluation orders Conditional statements.
ECE 103 Engineering Programming Chapter 11 One Minute Synopsis Herbert G. Mayer, PSU CS Status 7/1/2014.
Chapter 4 Control Structures I. Objectives ► Examine relational and logical operators ► Explore how to form and evaluate logical (Boolean) expressions.
True or false A variable of type char can hold the value 301. ( F )
Program Design and Development
Java Syntax Primitive data types Operators Control statements.
CS 225 Java Review. Java Applications A java application consists of one or more classes –Each class is in a separate file –Use the main class to start.
Quiz 1 Exam 1 Next Week. Nested if Statements if (myGrade >= 80) if (myGrade >= 90) cout
CIS Computer Programming Logic
DAT602 Database Application Development Lecture 5 JAVA Review.
 For Loops › for (variable set; condition; incremental or decrement){ // loop beginning › } // loop end  While loops › while (condition) { // beginning.
Chap 3 – PHP Quick Start COMP RL Professor Mattos.
Language Elements 1. Data Types 2 Floating Point (real) Single Precision Double Precision Decimal Fixed Point (integer) Byte Short Integer Long Numerical.
Arrays in C++ Numeric Character. Structured Data Type A structured data type is a type that stores a collection of individual components with one variable.
More on Input Output Input Stream : A sequence of characters from an input device (like the keyboard) to the computer (the program running). Output Stream.
Selection (if-then-else) Programming Has 3 Types of Control: Sequential (normal): Control of Execution Proceeds One after the Other Selection (if-then-else):
CSCI 3328 Object Oriented Programming in C# Chapter 5: C# Control Statement – Part II UTPA – Fall
Java means Coffee Java Coffee Beans The name “JAVA” was taken from a cup of coffee.
Chapter 7 Array processing. Objectives To introduce arrays and the uses of arrays To develop pseudocode algorithms for common operations on arrays To.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
C STRUCTURES. A FIRST C PROGRAM  #include  void main ( void )  { float height, width, area, wood_length ;  scanf ( "%f", &height ) ;  scanf ( "%f",
Expressions An expression is a series of variables, operators, and method calls (constructed according to the syntax of the language) that evaluates to.
COMPUTER PROGRAMMING II SUMMER 2011 Visual Basic to C#
Copyright © 2002, Department of Systems and Computer Engineering, Carleton University CONTROL STRUCTURES Simple If: if (boolean exp) { statements.
Data Structure and c K.S.Prabhu Lecturer All Deaf Educational Technology.
/* C Programming for the Absolute Beginner */ // by Michael Vine #include main() { printf(“\nC you later\n”); system(“pause”); }
Copyright © 2002, Department of Systems and Computer Engineering, Carleton University 1 INPUT STREAMS ifstream xin; // declares an input stream.
More loops while and do-while. Recall the for loop in general for (initialization; boolean_expression; update) { }
Variables and Constants Objectives F To understand Identifiers, Variables, and Constants.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
Lecture 15: Course Review BJ Furman ME 30 16MAY2011.
Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.
CPS120 Introduction to Computer Science Exam Review Lecture 18.
C++ Array 1. C++ provides a data structure, the array, which stores a fixed-size sequential collection of elements of the same type. An array is used.
13/10/2016CS150 Introduction to Computer Science 1 Multidimensional Arrays  Arrays can have more than one column  Two dimensional arrays have two columns.
Chad’s C++ Tutorial Demo Outline. 1. What is C++? C++ is an object-oriented programming (OOP) language that is viewed by many as the best language for.
CS 115 OBJECT ORIENTED PROGRAMMING I LECTURE 11 GEORGE KOUTSOGIANNAKIS 1 Copyright: 2015 Illinois Institute of Technology_ George Koutsogiannakis.
1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,
C syntax (simplified) BNF. Program ::= [ ] Directives ::= [ ] ::= | |… ::=#include > ::=#define.
Introduction to programming in java Lecture 21 Arrays – Part 1.
Computer Skills2 / Scientific Colleges 1 Arrays Topics to cover: Arrays Data Types One-dimensional Arrays Two-dimensional Arrays.
Java Programming Language Lecture27- An Introduction.
Selection (if-then-else) Programming Has 3 Types of Control: Sequential (normal): Control of Execution Proceeds One after the Other Selection (if-then-else):
Quiz 1 Exam 1 Next Monday. Nested if Statements if (myGrade >= 80) if (myGrade >= 90) System.out.println(“You have an A!” ); else System.out.println(“You.
C++ Lesson 1.
Chapter 1.2 Introduction to C++ Programming
IGCSE 4 Cambridge Data types and arrays Computer Science Section 2
Chapter 1.2 Introduction to C++ Programming
CS Computer Science IA: Procedural Programming
ECE Application Programming
Test Review Computer Science History
BY GAWARE S.R. COMPUTER SCI. DEPARTMENT
Expressions and Control Flow in JavaScript
11/10/2018.
Paskal Dil Karşılaştırması
Arrays, For loop While loop Do while loop
An Introduction to Java – Part I, language basics
An overview of Java, Data types and variables
Local Variables, Global Variables and Variable Scope
Standard Input/Output Stream
CS150 Introduction to Computer Science 1
2. Second Step for Learning C++ Programming • Data Type • Char • Float
CS150 Introduction to Computer Science 1
Fundamental Programming
Presentation transcript:

Translating Pseudocode into computer languages Lecture 14

Data Types PseudocodePascal/DelphiC++ Integer Floating point Boolean Character String Integer Single, Double Boolean Char String int, long float, double bool char string

PseudocodePascal/DelphiC++ Name Statement/s END PROCEDURE Name(parameter if any); BEGIN Statement/s ; END; FUNCTION Name(parameter if any): datatype; BEGIN statement/s; Name := returnValue; or RESULT := returnValue; END; void Name(parameter if any); { statement/s; } ; datatype Name(parameter if any) { statement/s; return value; }; Module Declaration

Variable & Constant Declaration PseudocodePascal/DelphiC++ Variable DeclarationVAR variableName1,...:datatype;datatype variableName1,... ; CONSTNAME = valueCONST CONSTNAME = value;const datatype CONSTNAME = value;

Assigning Value PseudocodePascal/DelphiC++ SET variableName TO value or variableName = value variableName := value ;variableName = value ;

Conditinal Operators PseudocodePascal/DelphiC++ operand = operand operand NOT = operand operand < operand operand > operand operand <= operand (operand = operand) (operand <> operand) (operand < operand) (operand > operand) (operand <= operand) (operand == operand) (operand != operand) (operand < operand) (operand > operand) (operand <= operand)

Logical Operators PseudocodePascal/DelphiC++ operand AND operand operand OR operand operand NOT operand operand AND operand operand OR operand NOT (operand) (operand && operand) (operand || operand) ! (operand)

IF ELSE PseudocodePascal/DelphiC++ IF (condition) THEN True statement/s block ELSE False statement/s block ENDIF IF (condition) THEN BEGIN True statement/s block; END ELSE BEGIN False statement/s block; END; if (condition) { True statement/s block; } else { False statement/s block; };

CASE OF PseudocodePascal/DelphiC++ CASE OF single_variable value_1 : statement block_1 value_2 : statement block_2... value_n : statement block_n value_other : statement block_other ENDCASE CASE single_variable OF value_1 : statement block_1; value_2 : statement block_2;... value_n : statement block_n; ELSE statement block_other; END; SWITCH (single_variable) { case value_1 : statement/s ; break; case value_2 : statement/s; break;... case value_n : statement/s; break; default: statement/s; };

DO WHILE PseudocodePascal/DelphiC++ DO statement/s WHILE (condition) REPEAT statement/s; UNTIL NOT (condition); do { statement/s; } while (condition); DOWHILE (condition) statement/s ENDDO WHILE (condition) DO BEGIN statement/s; END; while (condition) { statement/s; };

REPEAT UNTIL PseudocodePascal/DelphiC++ REPEAT statement/s UNTIL (condition) REPEAT statement/s; UNTIL (condition); do { statement/s; } while !(condition);

COUNTER PseudocodePascal/DelphiC++ DO counter = begin TO end statement/s ENDDO FOR counter := begin TO end DO BEGIN statement/s; END; for (counter = begin; counter <= end; counter++) { statement/s; };

RECORD STRUCTURE PseudocodePascal/DelphiC++ Record structures recordName fieldname1 fieldname2... fieldnameN TYPE recordName = RECORD field1 : datatype; field2 : datatype;.... fieldN: datatype; END; struct recordNameType { datatype field1; datatype field2;.... datatype fieldN; };

Sequential Files -Reading PseudocodePascal/DelphiC++ Initial processing READ variableName DOWHILE NOT EOF.... READ variableName ENDDO Final processing Program Name(Input, Output, fileHandle) VAR fileHandle : TEXTFILE;... BEGIN ASSIGNFILE(fileHandle,´´sourcefile´´); RESET (fileHandle); {Open for Reading} WHILE NOT (EOF(fileHandle)) DO BEGIN.... READLN(fileHandle, variable); END;... CLOSEFILE(fileHandle); END. #include... Ifstream inFileHandle;... inFileHandle.open(``source file``);... inFileHandle >> variableName; while (!inFileHandle.eof()) {... inFileHandle >> variableName ; }; inFileHandle.close();

Sequential Files - Writing Pseudocod e Pascal/DelphiC++ WRITE variableName Program Name(Input, Output, fileHandle) VAR fileHandle : TEXTFILE;... BEGIN ASSIGNFILE(fileHandle,´´sourcefile´´); REWRITE (fileHandle); {Open for Reading} WRITELN(fileHandle, variable or value);... CLOSEFILE(fileHandle); END. #include... ofstream outFileHandle;... outFileHandle.open(``source file``);... outFileHandle << variableName<<`` ``; }; outFileHandle.close();

Arrays PseudocodePascal/DelphiC++ Declaring arrays One-dimensional SET arrayName(maxNumElements) VAR arrayName : ARRAY[begin.. end] OF datatype; datatype arrayName [maxNumElements]; Declaring arrays Two-dimensional SET arrayName (row, column) VAR arrayName : ARRAY[begin..maxrow, begin..maxcolumn] OF datatype; datatype arrayName [row][columns]; Processing Array Elements Assigning a value arrayName (index) = value Reading a value variableName = arrayName (index) arrayName [index] := value; variableName := arrayName [index]; arrayName [index] = value ; variableName = arrayName [index];

END OF THE CLASS Good Luck for The Examination 15 June 2005 E2, – 13.00