CONTENTS Processing structures and commands Control structures – Sequence Sequence – Selection Selection – Iteration Iteration Naming conventions – File.

Slides:



Advertisements
Similar presentations
Chapter 41 Variables and JSP Control Structures JavaServer Pages By Xue Bai.
Advertisements

Programming with Microsoft Visual Basic 2008 Fourth Edition
Programming with Microsoft Visual Basic th Edition
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
The Web Warrior Guide to Web Design Technologies
Lecture 2 Introduction to C Programming
Introduction to C Programming
 2000 Prentice Hall, Inc. All rights reserved. Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line.
Introduction to C Programming
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Pseudocode and Algorithms
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
Information Technology Center Hany Abdelwahab Computer Specialist.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
CS241 PASCAL I - Control Structures1 PASCAL I - Control Structures Philip Fees CS241.
Introduction to C Programming
CONTROL STATEMENTS Lakhbir Singh(Lect.IT) S.R.S.G.P.C.G. Ludhiana.
Adding Automated Functionality to Office Applications.
Programming Concepts MIT - AITI. Variables l A variable is a name associated with a piece of data l Variables allow you to store and manipulate data in.
Basic Elements of C++ Chapter 2.
11 Chapter 4 LOOPS AND FILES. 22 THE INCREMENT AND DECREMENT OPERATORS To increment a variable means to increase its value by one. To decrement a variable.
Visual Basic Chapter 1 Mr. Wangler.
Fundamentals of Python: First Programs
CIS Computer Programming Logic
Chapter 4: The Selection Structure
Introduction to Python
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
08/10/ Iteration Loops For … To … Next. 208/10/2015 Learning Objectives Define a program loop. State when a loop will end. State when the For.
Chapter 12: How Long Can This Go On?
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
By: Md Rezaul Huda Reza UNIVERSITY of South Asia 2 Md Rezaul Huda Reza UNIVERSITY of South Asia 2 2 Program.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
Mr. Dave Clausen1 La Cañada High School Chapter 6: Repetition Statements.
Chapter 6: The Repetition Structure
VBScript Language. What is VBScript Based on the Visual Basic family of languages Supports object oriented features Interpreted Loosely Typed Implicitly.
Introduction to Programming with RAPTOR
An Introduction to Programming with C++ Sixth Edition Chapter 7 The Repetition Structure.
Lecture 2: Introduction to C Programming. OBJECTIVES In this lecture you will learn:  To use simple input and output statements.  The fundamental data.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Control Statements I.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
JavaScript, Fourth Edition
8-1 Compilers Compiler A program that translates a high-level language program into machine code High-level languages provide a richer set of instructions.
Using Loops. Goals Understand how to create while loops in JavaScript. Understand how to create do/while loops in JavaScript. Understand how to create.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
CHAPTER 2 PROBLEM SOLVING USING C++ 1 C++ Programming PEG200/Saidatul Rahah.
Repetition Statements (Loops). 2 Introduction to Loops We all know that much of the work a computer does is repeated many times. When a program repeats.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Control structures in C by Dr P.Padmanabham Professor (CSE)&Director Bharat Institute of Engineering &Technology Hyderabad Mobile
While loops. Iteration We’ve seen many places where repetition is necessary in a problem. We’ve been using the for loop for that purpose For loops are.
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
An Introduction to Programming with C++ Sixth Edition Chapter 5 The Selection Structure.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Introduction to Programming G50PRO University of Nottingham Unit 6 : Control Flow Statements 2 Paul Tennent
CONTENTS Loop Statements Parts of a loop Types of Loops Nested Loops
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
REPETITION CONTROL STRUCTURE
CS170 – Week 1 Lecture 3: Foundation Ismail abumuhfouz.
Chapter 2 - Introduction to C Programming
The Selection Structure
Chapter 2 - Introduction to C Programming
Microsoft Access Illustrated
Chapter 10 Programming Fundamentals with JavaScript
Introduction to C++ Programming
T. Jumana Abu Shmais – AOU - Riyadh
Presentation transcript:

CONTENTS Processing structures and commands Control structures – Sequence Sequence – Selection Selection – Iteration Iteration Naming conventions – File names File names – Variable and object names Variable and object names Questions

All languages have a syntax composed of rules that specify the way the features can be manipulated to and process data and information. When code is written, it is often automatically checked by the application to see if the syntax rules have been met. If they have not, it will not run and will result in an error message.

Some of the fundamental elements are: – Special symbols (i.e. =, $, &, %, >, <, +) – Identifiers: names for variables, properties and functions. Often contains letters, digits, symbols, underscores but no spaces. – A command or instruction: a word that defines an activity to be performed by the program. – Reserved words: the words if, then, else, end, begin, for, array, true, false and so on are reserved words that are used by the language for special purposes. – Numbers and numerical operations symbols (+, /, x, -) – Characters and strings – Comments that describe the purpose or function of code

The basic instruction of any program is an assignment statement. Can you provide an example? An expression returns a calculated value that can be assigned to a variable or used in another expression or statement (e.g. Hours * Pay rate {Product of hours by pay rate}) Operators perform specific operations on various types of data. Some types of operators are: arithmetic operators (+, -, *, / etc.), Boolean operators (not, and, or), string operators (+ joins two strings) and relational operators (, =, =) Assignment statements and other statement structures can be treated as one instruction: a compound statement. Marked at the beginning or end by special symbols or reserved words (i.e. [...], {...}, BEGIN...END)

Special structures are used to control the processing pathway followed through the various parts of the program. There are three main types of structures that control: – The sequence of instructions to be executed. – The selection or branching of the instructions to be executed. – The iteration, or repetition, of instructions.

Sequence Programs execute the first line of code, followed by each subsequent line unless otherwise directed. Sometimes the program transfers the control to a block of code called a procedure or function. This occurs when a special function needs to be performed. Procedures and functions have previously been written in another part of the program. After they have been executed, the control is returned to the calling code. Procedures and functions perform tasks such as calculating as average, selecting some characters from a word or sorting a list of names.

Selection To make a program execute one block of code rather than another based on the result of a decision, we use a selection statement. For example, the calculation ‘one will be added to the total of boys’ will only be executed if the condition Sex = ‘Male’ is true: A two-branch structure is IF...THEN...ELSE...as shown by: A multiple-branch structure is frequently provided with a CASE or a SWITCH statement that can process more than two choices. A CASE structure is equivalent to a nested IF...THEN...ELSE structure.

For example, the calculation ‘one will be added to the total of boys’ will only be executed if the condition Sex = ‘Male’ is true: – IF Sex = “Male” THEN NumBoys = NumBoys + 1 Two-branch: – IF Sex = “Male” – THEN NumBoys = NumBoys + 1 {the condition evaluates to True} – ELSE NumGirls = NumGirls + 1 {the condition evaluates to False}

Iteration Also called repetition and looping. Executes statements repeatedly. The execution of the code is dependent on a condition being satisfied. Three types of repetition structure are: for-do, while-do and repeat-until (or do-while) loops. – For-do: repeat a segment of code a specific number of times. – While-do: performs a segment of code only if a nominated condition is true. The code will continue to be executed until the expression evaluates to false. Also called the pre-test loop. – Repeat-until: Also called post-loop and do-while loop. The code will always be executed at least once as the condition is tested only after the first pass through the code (such as 3-password entry system).

Need to be meaningful and consistent to make their use easier for the developer of the application. Also allows for easier modification, saving time and effort with fewer chances of mistakes. If using sensible names, there should be little chance of using a reserved word that has a special purpose (such as real, button, release, number, name and click).

File names Should include a reference to the type of data that is stored in the file, the version of the file and the purpose (i.e. HelloWorld programming example – 25 August 2011). The user should not need to open the file to ensure it is the correct one. File names should: – Be one word, or be joined by an underscore – Be only lowercase, or only have a capital for the first letter of each word – Not contain and symbols other than an underscore – Start with a letter – Be unique by making reference to the content, version and purpose.

Variable and object names Objects and variable names usually follow the following pattern with the first two being the minimum required: - The prefix indicates the type of object or the data stored (e.g. btn for button, int for integer, txt for text, vid for video clip and img for image). - The body describes the main purpose, such as calculate, name, animal. - The qualifier is a quality of the main purpose, such as first, tiger. - The suffix is additional information (e.g. 1, 2, 3, a, b, c, blue, green. Imganimallion3).

Questions 1) What occurs if syntax conventions aren’t met? 2) List and explain three fundamental elements. 3) Provide three examples of assignment statements you have used in your programming thus far. 4) What are four types of operators? 5) Describe the three control structures. 6) Why are naming conventions important? List your own example of a good file name.