Computer Programming: C++

Size: px
Start display at page:

Download "Computer Programming: C++"

Transcription

1 The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2003 Muath i.alnabris Computer Programming: C++ Experiment #3 Loops Part I

2 Contents Introduction For-Loop While Loop Do-While Loop Introduction Loops are used in programming to repeat a specific block until some end condition is met. For Loop Repeats a statement or group of statements while a given condition is true. It tests the condition before executing the loop body. Its syntax is: 2

3 How for loop works? 1. The initialization statement is executed only once at the beginning. 2. Then, the test expression is evaluated. 3. If the test expression is false, for loop is terminated. But if the test expression is true, codes inside body of for loop is executed and update expression is updated. 4. Again, the test expression is evaluated and this process repeats until the test expression is false. Flowchart of for Loop 3

4 Ex1:Write C++ Program to find factorial of a number In the program, user is asked to enter a positive integer which is stored in variable n (suppose user entered 5). Here is the working of for loop: 1. Initially, i is equal to 1, test expression is true, factorial becomes i is updated to 2, test expression is true, factorial becomes i is updated to 3, test expression is true, factorial becomes i is updated to 4, test expression is true, factorial becomes i is updated to 5, test expression is true, factorial becomes i is updated to 6, test expression is false, for loop is terminated. 4

5 In the above program, variable i is not used outside of the for loop. In such cases, it is better to declare the variable in for loop (at initialization statement). While Loop In computer programming, loop repeats a certain block of code until some end condition is met. The syntax of a while loop is How while loop works? 1. The while loop evaluates the test expression. 2. If the test expression is true, codes inside the body of while loop is evaluated. 3. Then, the test expression is evaluated again. This process goes on until the test expression is false. 4. When the test expression is false, while loop is terminated. 5

6 Flowchart of while Loop Ex2: Write C++ Program to find factorial of a number 6

7 In this program, user is asked to enter a positive integer which is stored in variable number. Let's suppose, user entered 4. Then, the while loop starts executing the code. Here's how while loop works: 1. Initially, i = 1, test expression i <= number is true and factorial becomes Variable i is updated to 2, test expression is true, factorial becomes Variable i is updated to 3, test expression is true, factorial becomes Variable i is updated to 4, test expression is true, factorial becomes Variable i is updated to 5, test expression is false and while loop is terminated. 7

8 do...while Loop The do...while loop is a variant of the while loop with one important difference. The body of do...while loop is executed once before the test expression is checked. The syntax of do..while loop is: How do...while loop works? 1. The codes inside the body of loop is executed at least once. Then, only the test expression is checked. 2. If the test expression is true, the body of loop is executed. This process continues until the test expression becomes false. 3. When the test expression is false, do...while loop is terminated. Flowchart of do...while Loop 8

9 Ex3: Write C++ Program to add numbers until user enters 0 9

10 Lab Work 1. Write Program Display multiplication table up to a given range. "User enter number and range required". 10

11 Homework 1. Write program make user enter two number and then Find GCD using while loop. 2. Program to Calculate Sum of Natural Numbers "user entered number ". 11

Computer Programming: C++

Computer Programming: C++ The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2003 Muath i.alnabris Computer Programming: C++ Experiment #4 Loops Part II Contents Loop Control Statement

More information

Computer Programming: C++

Computer Programming: C++ The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2003 Muath i.alnabris Computer Programming: C++ Experiment #7 Arrays Part II Passing Array to a Function

More information

Programming in C++ PART 2

Programming in C++ PART 2 Lecture 07-2 Programming in C++ PART 2 By Assistant Professor Dr. Ali Kattan 1 The while Loop and do..while loop In the previous lecture we studied the for Loop in C++. In this lecture we will cover iteration

More information

Arrays. Eng. Mohammed Abdualal

Arrays. Eng. Mohammed Abdualal Islamic University of Gaza Faculty of Engineering Computer Engineering Department Computer Programming Lab (ECOM 2114) Created by Eng: Mohammed Alokshiya Modified by Eng: Mohammed Abdualal Lab 9 Arrays

More information

Computer Programming, I. Laboratory Manual. Experiment #6. Loops

Computer Programming, I. Laboratory Manual. Experiment #6. Loops Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2005 Khaleel I. Shaheen Computer Programming, I Laboratory Manual Experiment #6

More information

Lab # 6. Using Subqueries and Set Operators. Eng. Alaa O Shama

Lab # 6. Using Subqueries and Set Operators. Eng. Alaa O Shama The Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM 4113: Database Lab Lab # 6 Using Subqueries and Set Operators Eng. Alaa O Shama November, 2015 Objectives:

More information

Computer Programming : C++

Computer Programming : C++ The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2003 Muath i.alnabris Computer Programming : C++ Experiment #1 Basics Contents Structure of a program

More information

Computer Programming, I. Laboratory Manual. Experiment #3. Selections

Computer Programming, I. Laboratory Manual. Experiment #3. Selections Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2005 Khaleel I. Shaheen Computer Programming, I Laboratory Manual Experiment #3

More information

Computer Programming, I. Laboratory Manual. Experiment #7. Methods

Computer Programming, I. Laboratory Manual. Experiment #7. Methods Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2005 Khaleel I. Shaheen Computer Programming, I Laboratory Manual Experiment #7

More information

Computer Programming, I. Laboratory Manual. Experiment #9. Multi-Dimensional Arrays

Computer Programming, I. Laboratory Manual. Experiment #9. Multi-Dimensional Arrays Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2005 Khaleel I. Shaheen Computer Programming, I Laboratory Manual Experiment #9

More information

Computer Programming, I. Laboratory Manual. Experiment #2. Elementary Programming

Computer Programming, I. Laboratory Manual. Experiment #2. Elementary Programming Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2005 Khaleel I. Shaheen Computer Programming, I Laboratory Manual Experiment #2

More information

Lab # 6. Data Manipulation Language (DML)

Lab # 6. Data Manipulation Language (DML) Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM 4113: Lab # 6 Data Manipulation Language (DML) Eng. Haneen El-Masry December, 2014 2 Objective To be more familiar

More information

Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 4111: Digital Systems Design Lab. Lab # 5. Concurrent Statements

Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 4111: Digital Systems Design Lab. Lab # 5. Concurrent Statements Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 4111: Digital Systems Design Lab Lab # 5 Concurrent Statements October, 2015 Introduction VHDL code is inherently concurrent

More information

Introduction. C provides two styles of flow control:

Introduction. C provides two styles of flow control: Introduction C provides two styles of flow control: Branching Looping Branching is deciding what actions to take and looping is deciding how many times to take a certain action. Branching constructs: if

More information

APPM 2460: Week Three For, While and If s

APPM 2460: Week Three For, While and If s APPM 2460: Week Three For, While and If s 1 Introduction Today we will learn a little more about programming. This time we will learn how to use for loops, while loops and if statements. 2 The For Loop

More information

Faculty of Engineering Computer Engineering Department Islamic University of Gaza C++ Programming Language Lab # 6 Functions

Faculty of Engineering Computer Engineering Department Islamic University of Gaza C++ Programming Language Lab # 6 Functions Faculty of Engineering Computer Engineering Department Islamic University of Gaza 2013 C++ Programming Language Lab # 6 Functions C++ Programming Language Lab # 6 Functions Objective: To be familiar with

More information

Combinational Digital Design. Laboratory Manual. Experiment #3. Boolean Algebra Continued

Combinational Digital Design. Laboratory Manual. Experiment #3. Boolean Algebra Continued The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2013 Khaleel I. Shaheen Combinational Digital Design Laboratory Manual Experiment #3 Boolean Algebra

More information

Selection Statement ( if )

Selection Statement ( if ) Islamic University Of Gaza Faculty of Engineering Computer Engineering Department Lab 4 Selection Statement ( if ) Eng. Ibraheem Lubbad October 10, 2016 In this lab we will constructs program that allow

More information

University of Technology. Laser & Optoelectronics Engineering Department. C++ Lab.

University of Technology. Laser & Optoelectronics Engineering Department. C++ Lab. University of Technology Laser & Optoelectronics Engineering Department C++ Lab. Fifth week Control Structures A program is usually not limited to a linear sequence of instructions. During its process

More information

JAVA PROGRAMMING LAB. ABSTRACT In this Lab you will learn to write programs for executing statements repeatedly using a while, do while and for loop

JAVA PROGRAMMING LAB. ABSTRACT In this Lab you will learn to write programs for executing statements repeatedly using a while, do while and for loop Islamic University of Gaza Faculty of Engineering Computer Engineering Dept. Computer Programming Lab (ECOM 2114) ABSTRACT In this Lab you will learn to write programs for executing statements repeatedly

More information

Loops. Eng. Mohammed Abdualal. Islamic University of Gaza. Faculty of Engineering. Computer Engineering Department

Loops. Eng. Mohammed Abdualal. Islamic University of Gaza. Faculty of Engineering. Computer Engineering Department Islamic University of Gaza Faculty of Engineering Computer Engineering Department Computer Programming Lab (ECOM 2114) Created by Eng: Mohammed Alokshiya Modified by Eng: Mohammed Abdualal Lab 6 Loops

More information

Lecture Transcript While and Do While Statements in C++

Lecture Transcript While and Do While Statements in C++ Lecture Transcript While and Do While Statements in C++ Hello and welcome back. In this lecture we are going to look at the while and do...while iteration statements in C++. Here is a quick recap of some

More information

Loops! Loops! Loops! Lecture 5 COP 3014 Fall September 25, 2017

Loops! Loops! Loops! Lecture 5 COP 3014 Fall September 25, 2017 Loops! Loops! Loops! Lecture 5 COP 3014 Fall 2017 September 25, 2017 Repetition Statements Repetition statements are called loops, and are used to repeat the same code mulitple times in succession. The

More information

JAVA PROGRAMMING LAB. ABSTRACT In this Lab you will learn to define and invoke void and return java methods

JAVA PROGRAMMING LAB. ABSTRACT In this Lab you will learn to define and invoke void and return java methods Islamic University of Gaza Faculty of Engineering Computer Engineering Dept. Computer Programming Lab (ECOM 2114) ABSTRACT In this Lab you will learn to define and invoke void and return java methods JAVA

More information

Loops / Repetition Statements

Loops / Repetition Statements Loops / Repetition Statements Repetition statements allow us to execute a statement multiple times Often they are referred to as loops C has three kinds of repetition statements: the while loop the for

More information

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #16 Loops: Matrix Using Nested for Loop

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #16 Loops: Matrix Using Nested for Loop Introduction to Programming in C Department of Computer Science and Engineering Lecture No. #16 Loops: Matrix Using Nested for Loop In this section, we will use the, for loop to code of the matrix problem.

More information

Introduction to Computers. Laboratory Manual. Experiment #3. Elementary Programming, II

Introduction to Computers. Laboratory Manual. Experiment #3. Elementary Programming, II Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 LNGG 1003 Khaleel I. Shaheen Introduction to Computers Laboratory Manual Experiment

More information

SQL Retrieving Data from Multiple Tables

SQL Retrieving Data from Multiple Tables The Islamic University of Gaza Faculty of Engineering Dept. of Computer Engineering Database Lab (ECOM 4113) Lab 5 SQL Retrieving Data from Multiple Tables Eng. Ibraheem Lubbad An SQL JOIN clause is used

More information

Assembly Language LAB

Assembly Language LAB Assembly Language LAB Islamic University Gaza Engineering Faculty Department of Computer Engineering 2013 ECOM 2125: Assembly Language LAB Created by: Eng. Ahmed M. Ayash Modified and Presented By: Eihab

More information

Reading Input from Text File

Reading Input from Text File Islamic University of Gaza Faculty of Engineering Computer Engineering Department Computer Programming Lab (ECOM 2114) Lab 5 Reading Input from Text File Eng. Mohammed Alokshiya November 2, 2014 The simplest

More information

C++ Programming: From Problem Analysis to Program Design, Third Edition

C++ Programming: From Problem Analysis to Program Design, Third Edition C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 5: Control Structures II (Repetition) Why Is Repetition Needed? Repetition allows you to efficiently use variables Can input,

More information

Assembly Language LAB

Assembly Language LAB Assembly Language LAB Islamic University Gaza Engineering Faculty Department of Computer Engineering 2013 ECOM 2125: Assembly Language LAB Created by: Eng. Ahmed M. Ayash Modified and Presented By: Eihab

More information

Eng. Mohammed S. Abdualal

Eng. Mohammed S. Abdualal Islamic University of Gaza Faculty of Engineering Computer Engineering Dept. Computer Programming Lab (ECOM 2114) Created by Eng: Mohammed Alokshiya Modified by Eng: Mohammed Abdualal Lab 3 Selections

More information

Dept. of CSE, IIT KGP

Dept. of CSE, IIT KGP Control Flow: Looping CS10001: Programming & Data Structures Pallab Dasgupta Professor, Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Types of Repeated Execution Loop: Group of

More information

Lab # 2. Sequential Statements

Lab # 2. Sequential Statements The Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM 4111: Digital System Lab Lab # 2 Sequential Statements Eng. Alaa O Shama September, 2015 Introduction In this

More information

Database Lab Lab 6 DML part 3

Database Lab Lab 6 DML part 3 Islamic University of Gaza Faculty of Engineering Department of Computer Engineering Fall 2011 ECOM 4113: Database System Lab Eng. Ahmed Abumarasa Database Lab Lab 6 DML part 3 Data Manipulation Language:

More information

JAVA PROGRAMMING LAB. ABSTRACT EXTRA LAB, In this Lab you will learn working with recursion, JRX, Java documentations

JAVA PROGRAMMING LAB. ABSTRACT EXTRA LAB, In this Lab you will learn working with recursion, JRX, Java documentations Islamic University of Gaza Faculty of Engineering Computer Engineering Dept. Computer Programming Lab (ECOM 2114) ABSTRACT EXTRA LAB, In this Lab you will learn working with recursion, JRX, Java documentations

More information

Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB. Lab # 10. Advanced Procedures

Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB. Lab # 10. Advanced Procedures Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB Lab # 10 Advanced Procedures May, 2014 1 Assembly Language LAB Stack Parameters There are

More information

n Group of statements that are executed repeatedly while some condition remains true

n Group of statements that are executed repeatedly while some condition remains true Looping 1 Loops n Group of statements that are executed repeatedly while some condition remains true n Each execution of the group of statements is called an iteration of the loop 2 Example counter 1,

More information

Islamic University of Gaza Computer Engineering Dept. C++ Programming. For Industrial And Electrical Engineering By Instructor: Ruba A.

Islamic University of Gaza Computer Engineering Dept. C++ Programming. For Industrial And Electrical Engineering By Instructor: Ruba A. Islamic University of Gaza Computer Engineering Dept. C++ Programming For Industrial And Electrical Engineering By Instructor: Ruba A. Salamh Chapter Four: Loops 2 Chapter Goals To implement while, for

More information

Computer Programming, I. Laboratory Manual. Final Exam Solution

Computer Programming, I. Laboratory Manual. Final Exam Solution Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2005 Khaleel I. Shaheen Computer Programming, I Laboratory Manual Final Exam Solution

More information

Lecture Programming in C++ PART 1. By Assistant Professor Dr. Ali Kattan

Lecture Programming in C++ PART 1. By Assistant Professor Dr. Ali Kattan Lecture 08-1 Programming in C++ PART 1 By Assistant Professor Dr. Ali Kattan 1 The Conditional Operator The conditional operator is similar to the if..else statement but has a shorter format. This is useful

More information

Computer Programming, I. Laboratory Manual. Experiment #4. Mathematical Functions & Characters

Computer Programming, I. Laboratory Manual. Experiment #4. Mathematical Functions & Characters Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2005 Khaleel I. Shaheen Computer Programming, I Laboratory Manual Experiment #4

More information

Islamic University of Gaza Faculty of Engineering Department of Computer Engineering Fall 2011 ECOM 4113: Database System Lab Eng.

Islamic University of Gaza Faculty of Engineering Department of Computer Engineering Fall 2011 ECOM 4113: Database System Lab Eng. Islamic University of Gaza Faculty of Engineering Department of Computer Engineering Fall 2011 ECOM 4113: Database System Lab Eng. Ahmed Abumarasa Database Lab Lab 2 Database Table Introduction: The previous

More information

Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB. Lab # 8. Conditional Processing

Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB. Lab # 8. Conditional Processing Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB Lab # 8 Conditional Processing April, 2014 1 Assembly Language LAB Unconditional Jump The

More information

Chapter 5: Control Structures II (Repetition) Objectives (cont d.) Objectives. while Looping (Repetition) Structure. Why Is Repetition Needed?

Chapter 5: Control Structures II (Repetition) Objectives (cont d.) Objectives. while Looping (Repetition) Structure. Why Is Repetition Needed? Chapter 5: Control Structures II (Repetition) Objectives In this chapter, you will: Learn about repetition (looping) control structures Explore how to construct and use countercontrolled, sentinel-controlled,

More information

OER on Loops in C Programming

OER on Loops in C Programming OER on Loops in C Programming Prepared by GROUP ID 537 B. Bala Nagendra Prasad (bbalanagendraprasad@gmail.com C. Naga Swaroopa (swarupabaalu@gmail.com) L. Hari Krishna (lhkmaths@gmail.com) 1 Table of Contents

More information

Lab1. Introduction to Python. Lab 4: Selection Statement. Eng. Mai Z. Alyazji

Lab1. Introduction to Python. Lab 4: Selection Statement. Eng. Mai Z. Alyazji Islamic University of Gaza Faculty of Engineering Computer Engineering Dept. Introduction to Computers Lab (ENGG 1003) Lab1 Introduction to Python Lab 4: Selection Statement Eng. Mai Z. Alyazji In this

More information

Lab # 4. Files & Queues in C

Lab # 4. Files & Queues in C Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM 4010: Lab # 4 Files & Queues in C Eng. Haneen El-Masry October, 2013 2 FILE * Files in C For C File I/O you need

More information

Aggregate Functions. Eng. Mohammed Alokshiya. Islamic University of Gaza. Faculty of Engineering. Computer Engineering Dept. Database Lab (ECOM 4113)

Aggregate Functions. Eng. Mohammed Alokshiya. Islamic University of Gaza. Faculty of Engineering. Computer Engineering Dept. Database Lab (ECOM 4113) Islamic University of Gaza Faculty of Engineering Computer Engineering Dept. Database Lab (ECOM 4113) Lab 4 Aggregate Functions Eng. Mohammed Alokshiya October 26, 2014 Unlike single-row functions, group

More information

Computer Programming, I. Laboratory Manual. Experiment #5. Strings & Text Files Input

Computer Programming, I. Laboratory Manual. Experiment #5. Strings & Text Files Input Think Twice Code Once The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2005 Khaleel I. Shaheen Computer Programming, I Laboratory Manual Experiment #5

More information

Lecture # 1. SPIM & MIPS Programming

Lecture # 1. SPIM & MIPS Programming Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 3010: Computer Architecture Discussion Lecture # 1 SPIM & MIPS Programming Eng. Nour Eldadah SPIM - Spim is a self-contained

More information

Introduction to Python

Introduction to Python Islamic University Of Gaza Faculty of Engineering Computer Engineering Department Lab 1 Introduction to Python Eng. Ibraheem Lubbad September 17, 2016 Introduction: Python is a high-level, object-oriented

More information

Second Term ( ) Department of Computer Science Foundation Year Program Umm Al Qura University, Makkah

Second Term ( ) Department of Computer Science Foundation Year Program Umm Al Qura University, Makkah COMPUTER PROGRAMMING SKILLS (4800153-3) CHAPTER 5: REPETITION STRUCTURE Second Term (1437-1438) Department of Computer Science Foundation Year Program Umm Al Qura University, Makkah Table of Contents Objectives

More information

Lab # 9. Java to Database Connection

Lab # 9. Java to Database Connection Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM 4113: Lab # 9 Java to Database Connection Eng. Haneen El-Masry December, 2014 2 Objective In this lab, we turn

More information

CHAPTER 2.2 CONTROL STRUCTURES (ITERATION) Dr. Shady Yehia Elmashad

CHAPTER 2.2 CONTROL STRUCTURES (ITERATION) Dr. Shady Yehia Elmashad CHAPTER 2.2 CONTROL STRUCTURES (ITERATION) Dr. Shady Yehia Elmashad Outline 1. C++ Iterative Constructs 2. The for Repetition Structure 3. Examples Using the for Structure 4. The while Repetition Structure

More information

Assembly Language Lab # 11 Kyboard input with int 16 & Macros

Assembly Language Lab # 11 Kyboard input with int 16 & Macros Faculty of Engineering Computer Engineering Department Islamic University of Gaza Assembly Language Lab # 11 Kyboard input with int 16 & Macros Eng AlaaIHaniya Assembly Language Fundamentals Part1: Bios

More information

Assembly Language Lab # 6

Assembly Language Lab # 6 Faculty of Engineering Computer Engineering Department Islamic University of Gaza 2011 Assembly Language Lab # 6 Boolean Instructions and Conditional Structured Eng. Doaa Abu Jabal Objective: Assembly

More information

LECTURE 5 Control Structures Part 2

LECTURE 5 Control Structures Part 2 LECTURE 5 Control Structures Part 2 REPETITION STATEMENTS Repetition statements are called loops, and are used to repeat the same code multiple times in succession. The number of repetitions is based on

More information

Chapter 4: Control structures. Repetition

Chapter 4: Control structures. Repetition Chapter 4: Control structures Repetition Loop Statements After reading and studying this Section, student should be able to Implement repetition control in a program using while statements. Implement repetition

More information

CS 106 Introduction to Computer Science I

CS 106 Introduction to Computer Science I CS 106 Introduction to Computer Science I 02 / 15 / 2016 Instructor: Michael Eckmann Questions? Comments? Loops to repeat code while loops for loops do while loops Today s Topics Logical operators Example

More information

C++ Programming Lecture 7 Control Structure I (Repetition) Part I

C++ Programming Lecture 7 Control Structure I (Repetition) Part I C++ Programming Lecture 7 Control Structure I (Repetition) Part I By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department while Repetition Structure I Repetition structure Programmer

More information

Approximations and Errors

Approximations and Errors The Islamic University of Gaza Faculty of Engineering Civil Engineering Department Numerical Analysis ECIV 3306 Chapter 3 Approximations and Errors Associate Prof. Mazen Abualtayef Civil Engineering Department,

More information

! definite loop: A loop that executes a known number of times. " The for loops we have seen so far are definite loops. ! We often use language like

! definite loop: A loop that executes a known number of times.  The for loops we have seen so far are definite loops. ! We often use language like Indefinite loops while loop! indefinite loop: A loop where it is not obvious in advance how many times it will execute.! We often use language like " "Keep looping as long as or while this condition is

More information

BIL101E: Introduction to Computers and Information systems Lecture 8

BIL101E: Introduction to Computers and Information systems Lecture 8 BIL101E: Introduction to Computers and Information systems Lecture 8 8.1 Algorithms 8.2 Pseudocode 8.3 Control Structures 8.4 Decision Making: Equality and Relational Operators 8.5 The if Selection Structure

More information

REPETITION CONTROL STRUCTURE LOGO

REPETITION CONTROL STRUCTURE LOGO CSC 128: FUNDAMENTALS OF COMPUTER PROBLEM SOLVING REPETITION CONTROL STRUCTURE 1 Contents 1 Introduction 2 for loop 3 while loop 4 do while loop 2 Introduction It is used when a statement or a block of

More information

Variable and Data Type I

Variable and Data Type I The Islamic University of Gaza Faculty of Engineering Dept. of Computer Engineering Intro. To Computers (LNGG 1003) Lab 2 Variable and Data Type I Eng. Ibraheem Lubbad February 18, 2017 Variable is reserved

More information

Sudeshna Sarkar Dept. of Computer Science & Engineering. Indian Institute of Technology Kharagpur

Sudeshna Sarkar Dept. of Computer Science & Engineering. Indian Institute of Technology Kharagpur Programming and Data Structure Sudeshna Sarkar Dept. of Computer Science & Engineering. Indian Institute of Technology Kharagpur Shortcuts in Assignment Statements A+=C A=A+C A-=B A=A-B A*=D A=A*D A/=E

More information

Chapter 4: Control structures

Chapter 4: Control structures Chapter 4: Control structures Repetition Loop Statements After reading and studying this Section, student should be able to Implement repetition control in a program using while statements. Implement repetition

More information

Assembly Language LAB

Assembly Language LAB Assembly Language LAB Islamic University Gaza Engineering Faculty Department of Computer Engineering 2013 ECOM 2125: Assembly Language LAB Eng. Ahmed M. Ayash Lab # 3 Data Transfer & Arithmetic February

More information

Variable and Data Type I

Variable and Data Type I Islamic University Of Gaza Faculty of Engineering Computer Engineering Department Lab 2 Variable and Data Type I Eng. Ibraheem Lubbad September 24, 2016 Variable is reserved a location in memory to store

More information

Computer Programming ECIV 2303 Chapter 6 Programming in MATLAB Instructor: Dr. Talal Skaik Islamic University of Gaza Faculty of Engineering

Computer Programming ECIV 2303 Chapter 6 Programming in MATLAB Instructor: Dr. Talal Skaik Islamic University of Gaza Faculty of Engineering Computer Programming ECIV 2303 Chapter 6 Programming in MATLAB Instructor: Dr. Talal Skaik Islamic University of Gaza Faculty of Engineering 1 Introduction A computer program is a sequence of computer

More information

DHA Suffa University CS 103 Object Oriented Programming Fall 2015 Lab #01: Introduction to C++

DHA Suffa University CS 103 Object Oriented Programming Fall 2015 Lab #01: Introduction to C++ DHA Suffa University CS 103 Object Oriented Programming Fall 2015 Lab #01: Introduction to C++ Objective: To Learn Basic input, output, and procedural part of C++. C++ Object-orientated programming language

More information

ECOM4311 Digital Systems Design

ECOM4311 Digital Systems Design ECOM 4311 Digital Systems Design Eng. Monther Abusultan Computer Engineering Dept. Islamic University of Gaza Page 1 Agenda 1. VHDL : Data Types Cont d 2. VHDL : Operators 3. VHDL : Signal Assignments

More information

Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB. Lab # 7. Procedures and the Stack

Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB. Lab # 7. Procedures and the Stack Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB Lab # 7 Procedures and the Stack April, 2014 1 Assembly Language LAB Runtime Stack and Stack

More information

UEE1302(1066) F12: Introduction to Computers and Programming Function (II) - Parameter

UEE1302(1066) F12: Introduction to Computers and Programming Function (II) - Parameter UEE1302(1066) F12: Introduction to Computers and Programming Function (II) - Parameter What you will learn from Lab 7 In this laboratory, you will understand how to use typical function prototype with

More information

Programming Languages

Programming Languages Programming Languages G22.2110-001 Fall 2010 Dr. Jean-Claude Franchitti New York University Computer Science Department Courant Institute of Mathematical Sciences Session 2: Assignment #1 I. Due Date Monday

More information

CS 199 Computer Programming. Spring 2018 Lecture 5 Control Statements

CS 199 Computer Programming. Spring 2018 Lecture 5 Control Statements CS 199 Computer Programming Spring 2018 Lecture 5 Control Statements Control Structures 3 control structures Sequence structure Programs executed sequentially by default Branch structure Unconditional

More information

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 14: OCT. 25TH INSTRUCTOR: JIAYIN WANG

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 14: OCT. 25TH INSTRUCTOR: JIAYIN WANG CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 14: OCT. 25TH INSTRUCTOR: JIAYIN WANG 1 Notice Assignments No new homework this week. Please make up the homework 1 5 & class exercises this week.

More information

DataBase Lab JAVA-DATABASE CONNECTION. Eng. Haneen El-masry

DataBase Lab JAVA-DATABASE CONNECTION. Eng. Haneen El-masry In the name of Allah Islamic University of Gaza Faculty of Engineering Computer Engineering Department ECOM 4113 DataBase Lab Lab # 9 JAVA-DATABASE CONNECTION El-masry 2013 Objective In this lab, we turn

More information

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #13. Loops: Do - While

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #13. Loops: Do - While Introduction to Programming in C Department of Computer Science and Engineering Lecture No. #13 Loops: Do - While So far we have been using while loops in C, now C programming language also provides you

More information

PROBLEM SOLVING WITH LOOPS. Chapter 7

PROBLEM SOLVING WITH LOOPS. Chapter 7 PROBLEM SOLVING WITH LOOPS Chapter 7 Concept of Repetition Structure Logic It is a computer task, that is used for Repeating a series of instructions many times. Ex. The Process of calculating the Total

More information

Final Exam 90 minutes Eng. Mohammed S. F. Abdual Al

Final Exam 90 minutes Eng. Mohammed S. F. Abdual Al Islamic University of Gaza Faculty of Engineering Computer Engineering Department Computer Programming Lab (ECOM 2124) Final Exam 90 minutes Eng. Mohammed S. F. Abdual Al Student name Student ID Please

More information

Chapter 6 (Part a) Conditional Processing

Chapter 6 (Part a) Conditional Processing Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2025: Assembly Language Discussion Chapter 6 (Part a) Conditional Processing Eng. Eman R. Habib April, 2014 2 Assembly

More information

Lab 8 (IP Addressing)

Lab 8 (IP Addressing) Islamic University of Gaza Faculty of engineering Computer Department. Computer Network Lab ECOM 4121 Prepared by : Eng. Eman Al- Kurdi Lab 8 (IP Addressing) Introduction: Each device on a network must

More information

Why Is Repetition Needed?

Why Is Repetition Needed? Why Is Repetition Needed? Repetition allows efficient use of variables. It lets you process many values using a small number of variables. For example, to add five numbers: Inefficient way: Declare a variable

More information

SPIM & MIPS Programming

SPIM & MIPS Programming Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 3010: Computer Architecture Discussion Lecture # 1 SPIM & MIPS Programming Eng. Eman R. Habib September, 2013 2 Computer

More information

Jawwal System (Linked Lists)

Jawwal System (Linked Lists) Islamic University of Gaza Faculty of Engineering Computer Engineering Department Data Structures & Algorithms (ECOM 3312) Objective Assignment 1 Jawwal System (Linked Lists) Learn how to implement the

More information

PDS Lab Section 16 Autumn Tutorial 3. C Programming Constructs

PDS Lab Section 16 Autumn Tutorial 3. C Programming Constructs PDS Lab Section 16 Autumn-2017 Tutorial 3 C Programming Constructs This flowchart shows how to find the roots of a Quadratic equation Ax 2 +Bx+C = 0 Start Input A,B,C x B 2 4AC False x If 0 True B x 2A

More information

Chapter 6 Exercises with solutions

Chapter 6 Exercises with solutions Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 3010: Computer Architecture Discussion Chapter 6 Exercises with solutions Eng. Eman R. Habib December, 2013 2 Computer

More information

Methods. Eng. Mohammed Abdualal

Methods. Eng. Mohammed Abdualal Islamic University of Gaza Faculty of Engineering Computer Engineering Department Computer Programming Lab (ECOM 2114) Created by Eng: Mohammed Alokshiya Modified by Eng: Mohammed Abdualal Lab 8 Methods

More information

Chapter (1) Eng. Mai Z. Alyazji

Chapter (1) Eng. Mai Z. Alyazji THE ISLAMIC UNIVERSITY OF GAZA ENGINEERING FACULTY DEPARTMENT OF COMPUTER ENGINEERING DIGITAL LOGIC DESIGN DISCUSSION ECOM 2012 Chapter (1) Eng. Mai Z. Alyazji September, 2016 1.1 List the octal and hexadecimal

More information

RELATIONAL AND LOGICAL OPERATORS

RELATIONAL AND LOGICAL OPERATORS Contents RELATIONAL AND LOGICAL OPERATORS... Relational Operators... Logical Operators... Using Relational and Logical Operators with Scalars... 2 Using Relational Operators with Numerical Arrays... 5

More information

Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB

Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB Islamic University Gaza Engineering Faculty Department of Computer Engineering ECOM 2125: Assembly Language LAB Lab # 9 Integer Arithmetic and Bit Manipulation April, 2014 1 Assembly Language LAB Bitwise

More information

Syntax of for loop is as follows: for (inite; terme; updatee) { block of statements executed if terme is true;

Syntax of for loop is as follows: for (inite; terme; updatee) { block of statements executed if terme is true; Birla Institute of Technology & Science, Pilani Computer Programming (CSF111) Lab-5 ---------------------------------------------------------------------------------------------------------------------------------------------

More information

V3 1/3/2015. Programming in C. Example 1. Example Ch 05 A 1. What if we want to process three different pairs of integers?

V3 1/3/2015. Programming in C. Example 1. Example Ch 05 A 1. What if we want to process three different pairs of integers? Programming in C 1 Example 1 What if we want to process three different pairs of integers? 2 Example 2 One solution is to copy and paste the necessary lines of code. Consider the following modification:

More information

Operating Systems Lab

Operating Systems Lab Operating Systems Lab Islamic University Gaza Engineering Faculty Department of Computer Engineering Fall 2012 ECOM 4010: Operating Systems Lab Eng: Ahmed M. Ayash Lab # 3 Fork() in C and C++ programming

More information

Programming Language. Control Structures: Repetition (while) Eng. Anis Nazer Second Semester

Programming Language. Control Structures: Repetition (while) Eng. Anis Nazer Second Semester Programming Language Control Structures: Repetition (while) Eng. Anis Nazer Second Semester 2017-2018 Repetition statements Control statements change the order which statements are executed Selection :

More information

Assembly Language Lab # 4 Data Transfer & Arithmetic (1)

Assembly Language Lab # 4 Data Transfer & Arithmetic (1) Faculty of Engineering Computer Engineering Department Islamic University of Gaza 2011 Assembly Language Lab # 4 Data Transfer & Arithmetic (1) Eng. Mohammad Elhindi Assembly Language Lab # 4 Data Transfer

More information

Introduction to Algorithms and Programming (COMP151)

Introduction to Algorithms and Programming (COMP151) Introduction to Algorithms and Programming (COMP151) A Student's Manual for Practice Exercises Dr. Mohamed Aissa m.issa@unizwa.edu.om 11i13 Summer 2014 Practice Exercises #1 Introduction Page 2 Practice

More information