BITG 1113: Array (Part 1) LECTURE 8

Size: px
Start display at page:

Download "BITG 1113: Array (Part 1) LECTURE 8"

Transcription

1 BITG 1113: Array (Part 1) LECTURE 8 1 1

2 LEARNING OUTCOMES At the end of this lecture, you should be able to: 1. Describe the fundamentals of arrays 2. Describe the types of array: One Dimensional (1 D) and Two Dimensional (2 D) 3. Write declaration, initialization and assignment 4. Manipulate data in arrays (operations on arrays) 5. Explore the applicability of arrays 2 2

3 WHAT IS AN ARRAY? 3 Array of bugs An array is a derived data type (derived from fundamental data type) It is a group of a fixed number of elements (values or variables) of the same data type, placed in consecutive memory locations that are acessed or referenced using the array name and a subscript (or also known as index). If the name of an array of 10 elements is ARY, then its elements will be referenced as : ARY[0], ARY[1], ARY[2],, ARY[9] WHY ARRAY? Array is used to store a large number of values of the same data type under a single variable. That means, for example, using an array we can store 5 different values of the same type (int for example) with ONE unique identifier without having to declare 5 different variables. E.g.: To store the Marks of 50 students. To record the Sales of 100 salesman.

4 BASIC OPERATIONS ON ARRAY Some basic operations performed on arrays are: Initializing elements of array Input data to an array Output data stored in an array Finding the largest and/or smallest element Computations Each operation requires ability to step through the elements of the array Easily accomplished by a for loop. 44

5 TYPES OF ARRAY : THE MEANING OF DIMENSION Types of array: One dimensional (1-D), Two dimensional (2-D), etc. The dimension of an array is the number of indices (subscripts) needed to select an element. Thus a one-dimensional array is a list of data, a twodimensional array a rectangle of data, a threedimensional array a block of data, etc. Like a regular variable, an array must be declared before it is used. Array is declared using [ ] operator. 5

6 THE DIMENSIONS OF ARRAY 1-D array: with 10 elements. 2-D array: with 20 elements (4 x 5) 3-D array with: 24 elements(2x3x4) 3-Dimensional 6

7 1-D ARRAY : DECLARATION AND MEMORY LAYOUT Declaration Syntax: data_type array_name[size]; (Note :number of elements in the array) Example: (Note: size declarator - is an integer constant > 0) int number[5]; allocates the following memory to the elements of array number: SUBSCRIPT number [0] [1] [2] [3] [4]????? first element second element third element fourth element fifth element 7 In C++ the subscript of the first element is always 0.

8 8 1-D ARRAY : DECLARATION AND MEMORY LAYOUT

9 1 D ARRAY DECLARATION IN C++ PROGRAM : EXAMPLES #include <iostream> a) #define SIZE 20 b) using namespace std; int main() { int Marks[SIZE]; char Names[20]; } Execution statements #include <iostream> using namespace std; int main() { const int SIZE = 20; } int Marks[SIZE]; char Names[20]; Execution statements 9 * SIZE : is a size declarator; it must be a constant. ** It is advisable to use named constant as size declarator. This eases program maintenance when the size of the array needs to be changed.

10 1 D ARRAY INITIALIZATION Initial values are given to the array elements during array declaration. Examples on array initialization: char vowels[5] = {'a', 'e', 'i', 'o', 'u'}; bool anskey[] ={true, true, false, true, false, false}; char word[] = "Hello"; vowels 'a' 'e' 'i' 'o' 'u' anskey true true false true false false word 'H' 'e' 'l' 'l' 'o' '\0' 10

11 1 D ARRAY INITIALIZATION int scores[9] = {23,45,12,67,95,45,56,34,83}; 11

12 12 1 D ARRAY INITIALIZATION : SOME VARIATIONS

13 1-D ARRAY : ACCESSING ARRAY ELEMENTS Subscripts are used to access individual elements of an array. General format to access an array element: array_name[subscript] Example: const int size = 5; double number[size]; for (int i=0; i<=4; ++i) number[i] = double(i) + 0.5; From the above statements, each element of the array is accessed and assigned with a value as follows : 13 number

14 1-D ARRAY : ACCESSING ARRAY ELEMENTS Array elements can be accessed and used as regular variables, such as the following: numbers[0] = 79.5; cout << numbers[0]; cin >> numbers[1]; numbers[4] = numbers[0] + numbers[1]; Arrays must be accessed via individual elements: cout << numbers; // not legal We can copy an array to another array with the same size and type but it is not legal to assign one array to another as shown below : Example: 14 int num1[5]={1,2,3,4,5}; int num2[5]; num2 = num1; //error

15 CONT ASSIGNING VALUES TO 1-D ARRAY Example : to copy elements of num1 into num2. int num1[5] = {1,2,3,4,5}, num2[5]; for(int i =0 ; i<5; i++) { num2[i]= num1[i]; //correct } 15

16 MORE EXAMPLES : ASSIGNING VALUES TO 1-D ARRAY int num[5]; int list[10]; 16

17 INPUT DATA TO 1-D ARRAY Beside Assignment or Initialization, another way to fill the array is by inputting values (read) Can be done using a loop the most appropriate is the for loop int scores[9]; for (i=0;i<9;i++) { cin >> scores[i]; } The input are: <enter> 17 17

18 DISPLAY DATA STORED IN 1-D ARRAY for (i=0; i<9; i++) { cout <<scores[i]<< \n ; } Output:

19 EXAMPLE OF 1-D ARRAY FLOWCHART int main() { for ( int i = 0; i < 20; i++) cin >> numbers[i]; for ( int i = 0; i < 20; i++) cout << numbers[i]; 19 }

20 #include <iostream> #include <iomanip> using namespace std; EXAMPLE : INPUT AND OUTPUT OF 1-D ARRAY int main() { int i, a[5]={2,4,6,8,10}, b[5], c[5]; cout<< Enter 5 numbers:\n ; for(i=0; i<5; i++) cin >> b[i]; cout<< setw(15)<< a << setw(10) << b << setw(10) << c << endl; 20 } for(i=0; i<5; i++) { c[i]= a[i] + b[i]; cout<< setw(15) << a[i] << setw(10) << b[i] << setw(10) << c[i] <<endl; } return 0; 20

21 Output : Enter 5 numbers: ary1 ary2 ary

22 EXAMPLE : DETERMINE THE MINIMUM VALUE #include <iostream> using namespace std; void main() { int i, score[5], min; } 22 cout<< Enter 5 scores:\n ; for(i=0; i<5; i++) cin >> score[i]; min = score[0]; Output : for(i=1; i<5; i++) { if(score[i] < min ) min = score[i]; } cout<< The lowest score is << min; Enter 5 scores: The minimum score is 55 22

23 OPERATIONS ON ARRAY : MORE EXAMPLES 23

24 EXCHANGING VALUES IN 1-D ARRAY : THE INCORRECT WAY Problem: To exchange the values between number[1] and number[3] 24 24

25 THE CORRECT WAY - USING TEMPORARY VARIABLE 25 25

26 EXAMPLE : EXCHANGING VALUES #include <iostream> using namespace std; int main() { int temp; int numbers[5] = {3,7,12,24,45}; cout << "Before exchange the value :"<< endl; for(int i=0; i<5; i++) cout << numbers[i] << ' '; temp = numbers[3]; numbers[3] = numbers[1]; numbers[1] = temp; cout<<"\nafter exchange the value :"<<endl; for(int i=0; i<5; i++) cout << numbers[i] << ' '; } cout << endl; return 0;

27 TWO-DIMENSIONAL ARRAYS A two dimensional array stores a fixed number of data as a collection of rows and columns. Sometimes called matrices or tables. Each element of a two-dimensional array has a row position and a column position. The declaration of a two-dimensional array requires a row size and a column size. Declaration syntax: data_type array_name[row_size][column_size]; o where row_size and column_size are expressions with positive integer values, and specify the number of rows and the number of columns, respectively, in the array. o Note :number of elements in the array = row_size X column_size

28 DECLARATION OF 2-D ARRAY First dimension specifies the number of rows in the array Second dimension specifies the number of columns in each row A consecutive block of 50 (row size X column size) memory locations are allocated

29 2-D ARRAY : DECLARATION AND MEMORY LAYOUT The statement int table [5][4]; means array table is an array of one-dimensional array (two-dimensional array) COLUMN SUBSCRIPT [0] [0] [1] [2] [3] [1] ROW SUBSCRIPT [2] [3] [4] Array_name

30 30 30 MEMORY LAYOUT OF 2-D ARRAY

31 EXAMPLE: DECLARATION OF 2-D ARRAY int data[2][3]; row column [ 0 ] [ 1 ] [ 0 ] [ 1 ] [ 2 ]?????? data 31

32 2-D ARRAY: DECLARATION AND INITIALIZATION Two-dimensional arrays can be initialized when they are declared: Elements of each row are enclosed within braces and separated by commas. All rows are enclosed within braces. For number arrays, if all elements of a row aren t specified, unspecified ones are set to

33 2-D ARRAY: DECLARATION AND INITIALIZATION double t[2][2] = { {0.1,0.2}, {1.1, 1.2} }; [ 0 ] [ 1 ] [ 0 ] [ 1 ] t 33 33

34 2-D ARRAY: DECLARATION AND INITIALIZATION Initialization : Some variations int table [5][4] = {0,1,2,3,10,11,12,13,20,21,22,23,30,31,32, 31,40,41,42,43}; int table [5][4] = {{0,1,2,3},{10,11,12,13},{20,21,22,23}, {30,31,32,31},{40,41,42,43}}; int table [5][4] = {{0,1},{10},{20,21,22},{30},{40,41,42,43}}; 34 34

35 2-D ARRAY : ACCESSING ARRAY ELEMENTS The name of the array holds the address of the first element of the array. To access an element in a two-dimensional array, you must specify the name of the array followed by: a row subscript, and a column subscript General format to access a 2-D array element: array_name[row_subscript][column_subscript] Nested for loops are often used when accessing elements of a two-dimensional array

36 EXAMPLE : ASSIGNING DATA VALUE TO ARRAY ELEMENT. 36

37 EXAMPLE : ASSIGNING DATA VALUE TO ARRAY ELEMENTS. Let us assume that we want to assign our 5 x 4 array as shown below The following code will perform the assignment : int table[5][4]; for(int r=0;r<5;r++) for(int c=0;c<4;c++) table[r][c]= r * 10 + c ; 37 37

38 EXAMPLE : ASSIGNING DATA VALUE TO ARRAY ELEMENTS. To assign the fifth row to 0: To assign the entire matrix to 0: 38 38

39 EXAMPLE : ASSIGNING DATA VALUE TO ARRAY ELEMENTS. int v[rsize][csize]; for (int i=0; i<rsize; ++i) //every row for (int j=0; j<csize; ++j )//every col v[i][j] = i+j; [ 1 ] [ 2 ] [ 0 ] [ 1 ] [ 2 ] V

40 EXAMPLE : INPUT DATA VALUES TO 2-D ARRAY ELEMENTS. double table[rsize][csize]; for (int i=0; i<rsize; ++i) //every row for (int j=0; j<csize; ++j )//every col cin >> table[i][j]; for(int r=0;r<5;r++) for(int c=0;c<4;c++) cin >> table[r][c]; 40 40

41 COMPUTATION AND OUTPUT The for statement is useful when performing computations on arrays. The index variable of the for statement can be used as an array subscript. Computations can be easily performed on an entire two-dimensional array, or on a sub set of the array

42 COMPUTATIONS Compute the average of an array with n rows and m columns. for(int i=0; i<n; ++i) { for(int j=0; j<m; ++j) { sum += array[i][j]; } } average = sum/(n*m); 42 42

43 COMPUTATIONS Compute the average of the nth row of a twodimensional array with r rows and c columns. for(int col=0; col < c; ++col) { sum += array[n][col]; } rowaverage = sum/c; 43 43

44 OUTPUT Two dimensional arrays are often printed in a row by row format, using nested for statements. When printing the row values of an array, be sure to print: whitespace (blank space) between the values in a row. a newline character at the end of each row

45 DISPLAYING DATA VALUE OF ARRAY ELEMENTS. int table [5][4] = {{0,1,2,3},{10,11,12,13},{20,21,22,23}, {30,31,32,31},{40,41,42,43}}; for(int r=0;r<5;r++) { for(int c=0;c<4;c++) cout << table[r][c] << ; cout << endl; } 45 45

46 #include <iostream> #include <iomanip> using namespace std; EXAMPLE: TWO DIMENSIONAL ARRAY int main() { int i,j, a[4][3]; for(i = 0; i < 4; i++) { cout << "Enter 3 numbers for row " << i+1 << " : "; for(j = 0; j < 3; j++) cin >> a[i][j]; cout << endl; } cout<<"elements of array are : "<<endl; 46 } for(i = 0; i < 4; i++) { for(j = 0; j < 3; j++) cout << setw(5) << a[i][j] ; cout << endl; } return 0; 46

47 EXERCISES 1) Find the output of the following codes: int row = 3; int col = 3; int mark[row][col] = {{1,2,3}, {4,5,6}, {7,8,9}}; cout<<mark[1][1]<<endl; cout<<mark[2][1]<<endl; cout<<mark[3][3]<<endl;

48 2) Find the output of these codes: 48 #define Row 3 #define Col 3 int main() { int i, j; int xyz[row][col] = {{1,2,3}, {4,5,6},{7,8,9}}; for (i = 0; i < Row; i++) for (j = 0; j < Col; j++) cout << xyz[i][j]<<endl; return 0; } // end main

49 3) Problem : Write a program to enter five names with the maximum length of each name is 25 characters. The program then displays the name in the reverse order of entry. This means that the last name will be displayed first, followed by the fourth, and so on. - END - 49

BITG 1233: Array (Part 1) LECTURE 8 (Sem 2, 17/18)

BITG 1233: Array (Part 1) LECTURE 8 (Sem 2, 17/18) BITG 1233: Array (Part 1) LECTURE 8 (Sem 2, 17/18) 1 LEARNING OUTCOMES At the end of this lecture, you should be able to: 1. Describe the fundamentals of arrays 2. Describe the types of array: One Dimensional

More information

Lecture 2 Arrays, Searching and Sorting (Arrays, multi-dimensional Arrays)

Lecture 2 Arrays, Searching and Sorting (Arrays, multi-dimensional Arrays) Lecture 2 Arrays, Searching and Sorting (Arrays, multi-dimensional Arrays) In this lecture, you will: Learn about arrays Explore how to declare and manipulate data into arrays Understand the meaning of

More information

TWO DIMENSIONAL ARRAY OR MATRIX common name scores Defined as scores[10][5] IE 10 rows x 5 columns showing name of each position; some values below

TWO DIMENSIONAL ARRAY OR MATRIX common name scores Defined as scores[10][5] IE 10 rows x 5 columns showing name of each position; some values below TWO DIMENSIONAL ARRAY OR MATRIX common name scores Defined as scores[10][5] IE 10 rows x 5 columns showing name of each position; some values below Values in the memory could be scores[1][2]=78 scores[0][2]=56

More information

Chapter 8 Arrays and Strings. Objectives. Objectives (cont d.) Introduction. Arrays 12/23/2016. In this chapter, you will:

Chapter 8 Arrays and Strings. Objectives. Objectives (cont d.) Introduction. Arrays 12/23/2016. In this chapter, you will: Chapter 8 Arrays and Strings Objectives In this chapter, you will: Learn about arrays Declare and manipulate data into arrays Learn about array index out of bounds Learn about the restrictions on array

More information

Kingdom of Saudi Arabia Princes Nora bint Abdul Rahman University College of Computer Since and Information System CS242 ARRAYS

Kingdom of Saudi Arabia Princes Nora bint Abdul Rahman University College of Computer Since and Information System CS242 ARRAYS Kingdom of Saudi Arabia Princes Nora bint Abdul Rahman University College of Computer Since and Information System CS242 1 ARRAYS Arrays 2 Arrays Structures of related data items Static entity (same size

More information

Chapter 01 Arrays Prepared By: Dr. Murad Magableh 2013

Chapter 01 Arrays Prepared By: Dr. Murad Magableh 2013 Chapter 01 Arrays Prepared By: Dr. Murad Magableh 2013 One Dimensional Q1: Write a program that declares two arrays of integers and fills them from the user. Then exchanges their values and display the

More information

What we will learn about this week: Declaring and referencing arrays. arrays as function arguments. Arrays

What we will learn about this week: Declaring and referencing arrays. arrays as function arguments. Arrays What we will learn about this week: Declaring and referencing arrays Arrays in memory Initializing arrays indexed variables arrays as function arguments Arrays a way of expressing many of the same variable

More information

Objectives. Chapter 8 Arrays and Strings. Objectives (cont d.) Introduction 12/14/2014. In this chapter, you will:

Objectives. Chapter 8 Arrays and Strings. Objectives (cont d.) Introduction 12/14/2014. In this chapter, you will: Objectives Chapter 8 Arrays and Strings In this chapter, you will: Learn about arrays Declare and manipulate data into arrays Learn about array index out of bounds Learn about the restrictions on array

More information

Outline. Introduction. Arrays declarations and initialization. Const variables. Character arrays. Static arrays. Examples.

Outline. Introduction. Arrays declarations and initialization. Const variables. Character arrays. Static arrays. Examples. Outline Introduction. Arrays declarations and initialization. Const variables. Character arrays. Static arrays. Examples. 1 Arrays I Array One type of data structures. Consecutive group of memory locations

More information

C++ PROGRAMMING SKILLS Part 4: Arrays

C++ PROGRAMMING SKILLS Part 4: Arrays C++ PROGRAMMING SKILLS Part 4: Arrays Outline Introduction to Arrays Declaring and Initializing Arrays Examples Using Arrays Sorting Arrays: Bubble Sort Passing Arrays to Functions Computing Mean, Median

More information

The American University in Cairo Department of Computer Science & Engineering CSCI &09 Dr. KHALIL Exam-I Fall 2011

The American University in Cairo Department of Computer Science & Engineering CSCI &09 Dr. KHALIL Exam-I Fall 2011 The American University in Cairo Department of Computer Science & Engineering CSCI 106-07&09 Dr. KHALIL Exam-I Fall 2011 Last Name :... ID:... First Name:... Form I Section No.: EXAMINATION INSTRUCTIONS

More information

Arrays. Week 4. Assylbek Jumagaliyev

Arrays. Week 4. Assylbek Jumagaliyev Arrays Week 4 Assylbek Jumagaliyev a.jumagaliyev@iitu.kz Introduction Arrays Structures of related data items Static entity (same size throughout program) A few types Pointer-based arrays (C-like) Arrays

More information

The University Of Michigan. EECS402 Lecture 05. Andrew M. Morgan. Savitch Ch. 5 Arrays Multi-Dimensional Arrays. Consider This Program

The University Of Michigan. EECS402 Lecture 05. Andrew M. Morgan. Savitch Ch. 5 Arrays Multi-Dimensional Arrays. Consider This Program The University Of Michigan Lecture 05 Andrew M. Morgan Savitch Ch. 5 Arrays Multi-Dimensional Arrays Consider This Program Write a program to input 3 ints and output each value and their sum, formatted

More information

7.1. Chapter 7: Arrays Hold Multiple Values. Array - Memory Layout. A single variable can only hold one value. Declared using [] operator:

7.1. Chapter 7: Arrays Hold Multiple Values. Array - Memory Layout. A single variable can only hold one value. Declared using [] operator: Chapter 7: 7.1 Arrays Arrays Hold Multiple Values Arrays Hold Multiple Values Array - Memory Layout A single variable can only hold one value int test; 95 Enough memory for 1 int What if we need to store

More information

CS242 COMPUTER PROGRAMMING

CS242 COMPUTER PROGRAMMING CS242 COMPUTER PROGRAMMING I.Safa a Alawneh Variables Outline 2 Data Type C++ Built-in Data Types o o o o bool Data Type char Data Type int Data Type Floating-Point Data Types Variable Declaration Initializing

More information

Review of Important Topics in CS1600. Functions Arrays C-strings

Review of Important Topics in CS1600. Functions Arrays C-strings Review of Important Topics in CS1600 Functions Arrays C-strings Array Basics Arrays An array is used to process a collection of data of the same type Examples: A list of names A list of temperatures Why

More information

5.1. Chapter 5: The Increment and Decrement Operators. The Increment and Decrement Operators. The Increment and Decrement Operators

5.1. Chapter 5: The Increment and Decrement Operators. The Increment and Decrement Operators. The Increment and Decrement Operators Chapter 5: 5.1 Looping The Increment and Decrement Operators The Increment and Decrement Operators The Increment and Decrement Operators ++ is the increment operator. It adds one to a variable. val++;

More information

1. In C++, reserved words are the same as predefined identifiers. a. True

1. In C++, reserved words are the same as predefined identifiers. a. True C++ Programming From Problem Analysis to Program Design 8th Edition Malik TEST BANK Full clear download (no formatting errors) at: https://testbankreal.com/download/c-programming-problem-analysis-program-design-8thedition-malik-test-bank/

More information

Here, type declares the base type of the array, which is the type of each element in the array size defines how many elements the array will hold

Here, type declares the base type of the array, which is the type of each element in the array size defines how many elements the array will hold Arrays 1. Introduction An array is a consecutive group of memory locations that all have the same name and the same type. A specific element in an array is accessed by an index. The lowest address corresponds

More information

Chapter 7 Array. Array. C++, How to Program

Chapter 7 Array. Array. C++, How to Program Chapter 7 Array C++, How to Program Deitel & Deitel Spring 2016 CISC 1600 Yanjun Li 1 Array Arrays are data structures containing related data items of same type. An array is a consecutive group of memory

More information

CMPS 221 Sample Final

CMPS 221 Sample Final Name: 1 CMPS 221 Sample Final 1. What is the purpose of having the parameter const int a[] as opposed to int a[] in a function declaration and definition? 2. What is the difference between cin.getline(str,

More information

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction Chapter 2: Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 1 Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers

More information

7.1. Chapter 7: Arrays Hold Multiple Values. Array - Memory Layout. Array Terminology. Array Terminology 8/23/2014. Arrays Hold Multiple Values

7.1. Chapter 7: Arrays Hold Multiple Values. Array - Memory Layout. Array Terminology. Array Terminology 8/23/2014. Arrays Hold Multiple Values Chapter 7: Arrays 7.1 Arrays Hold Multiple Values Arrays Hold Multiple Values Array: variable that can store multiple values of the same type Values are stored in adjacent memory locations Declared using

More information

Character Functions & Manipulators Arrays in C++ CS 16: Solving Problems with Computers I Lecture #10

Character Functions & Manipulators Arrays in C++ CS 16: Solving Problems with Computers I Lecture #10 Character Functions & Manipulators Arrays in C++ CS 16: Solving Problems with Computers I Lecture #10 Ziad Matni Dept. of Computer Science, UCSB Lecture Outline Useful character manipulators & functions

More information

FORM 1 (Please put your name and section number (001/10am or 002/2pm) on the scantron!!!!) CS 161 Exam II: True (A)/False(B) (2 pts each):

FORM 1 (Please put your name and section number (001/10am or 002/2pm) on the scantron!!!!) CS 161 Exam II: True (A)/False(B) (2 pts each): FORM 1 (Please put your name and section number (001/10am or 002/2pm) on the scantron!!!!) CS 161 Exam II: True (A)/False(B) (2 pts each): 1. If a function has default arguments, they can be located anywhere

More information

Chapter 2: Basic Elements of C++

Chapter 2: Basic Elements of C++ Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates

More information

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program Objectives Chapter 2: Basic Elements of C++ In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates

More information

STRUCTURED DATA TYPE ARRAYS IN C++ ONE-DIMENSIONAL ARRAY TWO-DIMENSIONAL ARRAY

STRUCTURED DATA TYPE ARRAYS IN C++ ONE-DIMENSIONAL ARRAY TWO-DIMENSIONAL ARRAY STRUCTURED DATA TYPE ARRAYS IN C++ ONE-DIMENSIONAL ARRAY TWO-DIMENSIONAL ARRAY Objectives Declaration of 1-D and 2-D Arrays Initialization of arrays Inputting array elements Accessing array elements Manipulation

More information

Maltepe University Computer Engineering Department. BİL 133 Algorithms and Programming. Chapter 8: Arrays

Maltepe University Computer Engineering Department. BİL 133 Algorithms and Programming. Chapter 8: Arrays Maltepe University Computer Engineering Department BİL 133 Algorithms and Programming Chapter 8: Arrays What is an Array? Scalar data types use a single memory cell to store a single value. For many problems

More information

1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol.

1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol. 1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol. B. Outputs to the console a floating point number f1 in scientific format

More information

Declaring a 2D Array

Declaring a 2D Array Lecture 13 Declaring a 2D Array Model: type name[row_size ][ column_size] Example: int grades[10][20]; string students[10][20]; 2D Array data structure Say we have the following array: int grades[4][8];

More information

Week 3: Pointers (Part 2)

Week 3: Pointers (Part 2) Advanced Programming (BETC 1353) Week 3: Pointers (Part 2) Dr. Abdul Kadir abdulkadir@utem.edu.my Learning Outcomes: Able to describe the concept of pointer expression and pointer arithmetic Able to explain

More information

Problem Solving: Storyboards for User Interaction

Problem Solving: Storyboards for User Interaction Topic 6 1. The while loop 2. Problem solving: hand-tracing 3. The for loop 4. The do loop 5. Processing input 6. Problem solving: storyboards 7. Common loop algorithms 8. Nested loops 9. Problem solving:

More information

Chapter 6 Pointers and Arrays

Chapter 6 Pointers and Arrays Chapter 6 Pointers and Arrays This chapter addresses the following two issues: 1. How to access a variable (memory location) using its address. 2. How to process a collection of data as a list or a table.

More information

Pointers. Variable Declaration. Chapter 10

Pointers. Variable Declaration. Chapter 10 Pointers Chapter 10 Variable Declaration When a variable is defined, three fundamental attributes are associated with it: Name Type Address The variable definition associates the name, the type, and the

More information

CHAPTER 3 ARRAYS. Dr. Shady Yehia Elmashad

CHAPTER 3 ARRAYS. Dr. Shady Yehia Elmashad CHAPTER 3 ARRAYS Dr. Shady Yehia Elmashad Outline 1. Introduction 2. Arrays 3. Declaring Arrays 4. Examples Using Arrays 5. Multidimensional Arrays 6. Multidimensional Arrays Examples 7. Examples Using

More information

Lab 2: Pointers. //declare a pointer variable ptr1 pointing to x. //change the value of x to 10 through ptr1

Lab 2: Pointers. //declare a pointer variable ptr1 pointing to x. //change the value of x to 10 through ptr1 Lab 2: Pointers 1. Goals Further understanding of pointer variables Passing parameters to functions by address (pointers) and by references Creating and using dynamic arrays Combing pointers, structures

More information

Week 3. Function Definitions. Example: Function. Function Call, Return Statement. Functions & Arrays. Gaddis: Chapters 6 and 7.

Week 3. Function Definitions. Example: Function. Function Call, Return Statement. Functions & Arrays. Gaddis: Chapters 6 and 7. Week 3 Functions & Arrays Gaddis: Chapters 6 and 7 CS 5301 Fall 2015 Jill Seaman 1 Function Definitions! Function definition pattern: datatype identifier (parameter1, parameter2,...) { statements... Where

More information

Objectives. In this chapter, you will:

Objectives. In this chapter, you will: Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates arithmetic expressions Learn about

More information

ARRAYS(II Unit Part II)

ARRAYS(II Unit Part II) ARRAYS(II Unit Part II) Array: An array is a collection of two or more adjacent cells of similar type. Each cell in an array is called as array element. Each array should be identified with a meaningful

More information

Computer Department. Question (1): State whether each of the following is true or false. Question (2): Select the correct answer from the following:

Computer Department. Question (1): State whether each of the following is true or false. Question (2): Select the correct answer from the following: Computer Department Program: Computer Midterm Exam Date : 19/11/2016 Major: Information & communication technology 1 st Semester Time : 1 hr (10:00 11:00) Course: Introduction to Programming 2016/2017

More information

Gabriel Hugh Elkaim Spring CMPE 013/L: C Programming. CMPE 013/L: C Programming

Gabriel Hugh Elkaim Spring CMPE 013/L: C Programming. CMPE 013/L: C Programming 1 2 3 CMPE 013/L and Strings Gabriel Hugh Elkaim Spring 2013 4 Definition are variables that can store many items of the same type. The individual items known as elements, are stored sequentially and are

More information

CSC 126 FINAL EXAMINATION Spring Total Possible TOTAL 100

CSC 126 FINAL EXAMINATION Spring Total Possible TOTAL 100 CSC 126 FINAL EXAMINATION Spring 2011 Version A Name (Last, First) Your Instructor Question # Total Possible 1. 10 Total Received 2. 15 3. 15 4. 10 5. 10 6. 10 7. 10 8. 20 TOTAL 100 Name: Sp 11 Page 2

More information

Object-oriented Programming for Automation & Robotics Carsten Gutwenger LS 11 Algorithm Engineering

Object-oriented Programming for Automation & Robotics Carsten Gutwenger LS 11 Algorithm Engineering Object-oriented Programming for Automation & Robotics Carsten Gutwenger LS 11 Algorithm Engineering Lecture 3 Winter 2011/12 Oct 25 Visual C++: Problems and Solutions New section on web page (scroll down)

More information

Tutorial 13 Salary Survey Application: Introducing One- Dimensional Arrays

Tutorial 13 Salary Survey Application: Introducing One- Dimensional Arrays Tutorial 13 Salary Survey Application: Introducing One- Dimensional Arrays Outline 13.1 Test-Driving the Salary Survey Application 13.2 Introducing Arrays 13.3 Declaring and Initializing Arrays 13.4 Constructing

More information

Lab #10 Multi-dimensional Arrays

Lab #10 Multi-dimensional Arrays Multi-dimensional Arrays Sheet s Owner Student ID Name Signature Group partner 1. Two-Dimensional Arrays Arrays that we have seen and used so far are one dimensional arrays, where each element is indexed

More information

CSC 307 DATA STRUCTURES AND ALGORITHM ANALYSIS IN C++ SPRING 2011

CSC 307 DATA STRUCTURES AND ALGORITHM ANALYSIS IN C++ SPRING 2011 CSC 307 DATA STRUCTURES AND ALGORITHM ANALYSIS IN C++ SPRING 2011 Date: 01/18/2011 (Due date: 01/20/2011) Name and ID (print): CHAPTER 6 USER-DEFINED FUNCTIONS I 1. The C++ function pow has parameters.

More information

! A program is a set of instructions that the. ! It must be translated. ! Variable: portion of memory that stores a value. char

! A program is a set of instructions that the. ! It must be translated. ! Variable: portion of memory that stores a value. char Week 1 Operators, Data Types & I/O Gaddis: Chapters 1, 2, 3 CS 5301 Fall 2016 Jill Seaman Programming A program is a set of instructions that the computer follows to perform a task It must be translated

More information

Exam 3 Chapters 7 & 9

Exam 3 Chapters 7 & 9 Exam 3 Chapters 7 & 9 CSC 2100-002/003 29 Mar 2017 Read through the entire test first BEFORE starting Put your name at the TOP of every page The test has 4 sections worth a total of 100 points o True/False

More information

CS101: Fundamentals of Computer Programming. Dr. Tejada www-bcf.usc.edu/~stejada Week 1 Basic Elements of C++

CS101: Fundamentals of Computer Programming. Dr. Tejada www-bcf.usc.edu/~stejada Week 1 Basic Elements of C++ CS101: Fundamentals of Computer Programming Dr. Tejada stejada@usc.edu www-bcf.usc.edu/~stejada Week 1 Basic Elements of C++ 10 Stacks of Coins You have 10 stacks with 10 coins each that look and feel

More information

Chapter 4 - Arrays. 4.1 Introduction. Arrays Structures of related data items Static entity (same size throughout program) A few types

Chapter 4 - Arrays. 4.1 Introduction. Arrays Structures of related data items Static entity (same size throughout program) A few types Chapter 4 - Arrays 1 4.1 Introduction 4.2 Arrays 4.3 Declaring Arrays 4.4 Examples Using Arrays 4.5 Passing Arrays to Functions 4.6 Sorting Arrays 4.7 Case Study: Computing Mean, Median and Mode Using

More information

Lecture 3 Tao Wang 1

Lecture 3 Tao Wang 1 Lecture 3 Tao Wang 1 Objectives In this chapter, you will learn about: Arithmetic operations Variables and declaration statements Program input using the cin object Common programming errors C++ for Engineers

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

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

Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. CMPSC11 Final (Study Guide) Fall 11 Prof Hartman Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) This is a collection of statements that performs

More information

Array Part dimensional arrays - 2-dimensional array operations - Arrays of Strings - N-dimensional arrays

Array Part dimensional arrays - 2-dimensional array operations - Arrays of Strings - N-dimensional arrays Array Array Part 1 - Accessing array - Array and loop arrays must be used with loops - Array and bound checking Be careful of array bound: invalid subscripts => corrupt memory; cause bugs - Array initialization

More information

Lab Instructor : Jean Lai

Lab Instructor : Jean Lai Lab Instructor : Jean Lai Group related statements to perform a specific task. Structure the program (No duplicate codes!) Must be declared before used. Can be invoked (called) as any number of times.

More information

Chapter 4 - Arrays. 4.1 Introduction. Arrays Structures of related data items Static entity (same size throughout program)

Chapter 4 - Arrays. 4.1 Introduction. Arrays Structures of related data items Static entity (same size throughout program) Chapter - Arrays 1.1 Introduction 2.1 Introduction.2 Arrays.3 Declaring Arrays. Examples Using Arrays.5 Passing Arrays to Functions.6 Sorting Arrays. Case Study: Computing Mean, Median and Mode Using Arrays.8

More information

Week 3. Function Definitions. Example: Function. Function Call, Return Statement. Functions & Arrays. Gaddis: Chapters 6 and 7. CS 5301 Spring 2018

Week 3. Function Definitions. Example: Function. Function Call, Return Statement. Functions & Arrays. Gaddis: Chapters 6 and 7. CS 5301 Spring 2018 Week 3 Functions & Arrays Gaddis: Chapters 6 and 7 CS 5301 Spring 2018 Jill Seaman 1 Function Definitions l Function definition pattern: datatype identifier (parameter1, parameter2,...) { statements...

More information

CS2141 Software Development using C/C++ C++ Basics

CS2141 Software Development using C/C++ C++ Basics CS2141 Software Development using C/C++ C++ Basics Integers Basic Types Can be short, long, or just plain int C++ does not define the size of them other than short

More information

9.1 The Array Data Type. Data Structures Arrays and Structs. Arrays. Arrays. Array Declaration. Arrays. Array elements have a common name

9.1 The Array Data Type. Data Structures Arrays and Structs. Arrays. Arrays. Array Declaration. Arrays. Array elements have a common name 9.1 The Array Data Type Data Structures Arrays and Structs Chapter 9 Array elements have a common name The array as a whole is referenced through the common name Array elements are of the same type the

More information

Chapter 2 Basic Elements of C++

Chapter 2 Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 2-1 Chapter 2 Basic Elements of C++ At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion

More information

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible) Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program

More information

CSCE 110 PROGRAMMING FUNDAMENTALS. Prof. Amr Goneid AUC Part 7. 1-D & 2-D Arrays

CSCE 110 PROGRAMMING FUNDAMENTALS. Prof. Amr Goneid AUC Part 7. 1-D & 2-D Arrays CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++ Prof. Amr Goneid AUC Part 7. 1-D & 2-D Arrays Prof. Amr Goneid, AUC 1 Arrays Prof. Amr Goneid, AUC 2 1-D Arrays Data Structures The Array Data Type How to Declare

More information

UEE1302 (1102) F10 Introduction to Computers and Programming (I)

UEE1302 (1102) F10 Introduction to Computers and Programming (I) Computational Intelligence on Automation Lab @ NCTU UEE1302 (1102) F10 Introduction to Computers and Programming (I) Programming Lecture 07 Arrays: Basics and Multi-dimensional Arrays Learning Objectives

More information

Chapter 4 - Notes Control Structures I (Selection)

Chapter 4 - Notes Control Structures I (Selection) Chapter 4 - Notes Control Structures I (Selection) I. Control Structures A. Three Ways to Process a Program 1. In Sequence: Starts at the beginning and follows the statements in order 2. Selectively (by

More information

Sample Code: OUTPUT Daily Highs & Lows

Sample Code: OUTPUT Daily Highs & Lows Name1: Name2: Class Day / Time: Due Date: Sample Code: OUTPUT Daily Highs & Lows This program will obtain from the user 3 sets of data including a date, the high temperature and a low temperature for that

More information

Practice Exercises #8

Practice Exercises #8 Practice Exercises #8 Chapter 6 Functions Page 1 Practice Exercises #8 Functions Related Chapter Chapter Title 6 Functions STUDENT LEARNING OUTCOMES: Upon completion of this practical exercise, a successful

More information

1. To introduce and allow students to work with arrays 2. To introduce the typedef statement 3. To work with and manipulate multidimensional arrays

1. To introduce and allow students to work with arrays 2. To introduce the typedef statement 3. To work with and manipulate multidimensional arrays L E S S O N S E T 7 Arrays PURPOSE PROCEDURE 1. To introduce and allow students to work with arrays 2. To introduce the typedef statement 3. To work with and manipulate multidimensional arrays 1. Students

More information

Computer Science II Lecture 2 Strings, Vectors and Recursion

Computer Science II Lecture 2 Strings, Vectors and Recursion 1 Overview of Lecture 2 Computer Science II Lecture 2 Strings, Vectors and Recursion The following topics will be covered quickly strings vectors as smart arrays Basic recursion Mostly, these are assumed

More information

Review. Outline. Array Pointer Object-Oriented Programming. Fall 2013 CISC2200 Yanjun Li 1. Fall 2013 CISC2200 Yanjun Li 2

Review. Outline. Array Pointer Object-Oriented Programming. Fall 2013 CISC2200 Yanjun Li 1. Fall 2013 CISC2200 Yanjun Li 2 Review Fall 2013 CISC2200 Yanjun Li 1 Outline Array Pointer Object-Oriented Programming Fall 2013 CISC2200 Yanjun Li 2 1 Array Arrays are data structures containing related data items of same type. An

More information

Functions, Arrays & Structs

Functions, Arrays & Structs Functions, Arrays & Structs Unit 1 Chapters 6-7, 11 Function Definitions l Function definition pattern: datatype identifier (parameter1, parameter2,...) { statements... Where a parameter is: datatype identifier

More information

Review. Outline. Array Pointer Object-Oriented Programming. Fall 2017 CISC2200 Yanjun Li 1. Fall 2017 CISC2200 Yanjun Li 2

Review. Outline. Array Pointer Object-Oriented Programming. Fall 2017 CISC2200 Yanjun Li 1. Fall 2017 CISC2200 Yanjun Li 2 Review Fall 2017 CISC2200 Yanjun Li 1 Outline Array Pointer Object-Oriented Programming Fall 2017 CISC2200 Yanjun Li 2 1 Computer Fall 2017 CISC2200 Yanjun Li 3 Array Arrays are data structures containing

More information

BITG 1113: Function (Part 2) LECTURE 5

BITG 1113: Function (Part 2) LECTURE 5 BITG 1113: Function (Part 2) LECTURE 5 1 Learning Outcomes At the end of this lecture, you should be able to: explain parameter passing in programs using: Pass by Value and Pass by Reference. use reference

More information

Arrays. Defining arrays, declaration and initialization of arrays. Designed by Parul Khurana, LIECA.

Arrays. Defining arrays, declaration and initialization of arrays. Designed by Parul Khurana, LIECA. Arrays Defining arrays, declaration and initialization of arrays Introduction Many applications require the processing of multiple data items that have common characteristics (e.g., a set of numerical

More information

BITG 1233: Introduction to C++

BITG 1233: Introduction to C++ BITG 1233: Introduction to C++ 1 Learning Outcomes At the end of this lecture, you should be able to: Identify basic structure of C++ program (pg 3) Describe the concepts of : Character set. (pg 11) Token

More information

Agenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures

Agenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures The main body and cout Agenda 1 Fundamental data types Declarations and definitions Control structures References, pass-by-value vs pass-by-references The main body and cout 2 C++ IS AN OO EXTENSION OF

More information

CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING Chapter 6: One Dimensional Array

CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING Chapter 6: One Dimensional Array Lesson Outcomes At the end of this chapter, student should be able to: Define array Understand requirement of array Know how to access elements of an array Write program using array Know how to pass array

More information

Chapter 7 - Notes User-Defined Functions II

Chapter 7 - Notes User-Defined Functions II Chapter 7 - Notes User-Defined Functions II I. VOID Functions ( The use of a void function is done as a stand alone statement.) A. Void Functions without Parameters 1. Syntax: void functionname ( void

More information

Fundamentals of Programming CS-110. Lecture 2

Fundamentals of Programming CS-110. Lecture 2 Fundamentals of Programming CS-110 Lecture 2 Last Lab // Example program #include using namespace std; int main() { cout

More information

The C++ Language. Arizona State University 1

The C++ Language. Arizona State University 1 The C++ Language CSE100 Principles of Programming with C++ (based off Chapter 2 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona State University

More information

1 Unit 8 'for' Loops

1 Unit 8 'for' Loops 1 Unit 8 'for' Loops 2 Control Structures We need ways of making decisions in our program To repeat code until we want it to stop To only execute certain code if a condition is true To execute one segment

More information

Structured Programming. Flowchart Symbols. Structured Programming. Selection. Sequence. Control Structures ELEC 330 1

Structured Programming. Flowchart Symbols. Structured Programming. Selection. Sequence. Control Structures ELEC 330 1 ELEC 330 1 Structured Programming Control Structures ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne Algorithm Development Conditional Expressions Selection Statements Loops 206_C3

More information

Lesson 06 Arrays. MIT 11053, Fundamentals of Programming By: S. Sabraz Nawaz Senior Lecturer in MIT Department of MIT FMC, SEUSL

Lesson 06 Arrays. MIT 11053, Fundamentals of Programming By: S. Sabraz Nawaz Senior Lecturer in MIT Department of MIT FMC, SEUSL Lesson 06 Arrays MIT 11053, Fundamentals of Programming By: S. Sabraz Nawaz Senior Lecturer in MIT Department of MIT FMC, SEUSL Array An array is a group of variables (called elements or components) containing

More information

calling a function - function-name(argument list); y = square ( z ); include parentheses even if parameter list is empty!

calling a function - function-name(argument list); y = square ( z ); include parentheses even if parameter list is empty! Chapter 6 - Functions return type void or a valid data type ( int, double, char, etc) name parameter list void or a list of parameters separated by commas body return keyword required if function returns

More information

Increment and the While. Class 15

Increment and the While. Class 15 Increment and the While Class 15 Increment and Decrement Operators Increment and Decrement Increase or decrease a value by one, respectively. the most common operation in all of programming is to increment

More information

Starting Out with C++: Early Objects, 9 th ed. (Gaddis, Walters & Muganda) Chapter 2 Introduction to C++ Chapter 2 Test 1 Key

Starting Out with C++: Early Objects, 9 th ed. (Gaddis, Walters & Muganda) Chapter 2 Introduction to C++ Chapter 2 Test 1 Key Starting Out with C++ Early Objects 9th Edition Gaddis TEST BANK Full clear download (no formatting errors) at: https://testbankreal.com/download/starting-c-early-objects-9thedition-gaddis-test-bank/ Starting

More information

BITG 1113: Array (Part 2) LECTURE 9

BITG 1113: Array (Part 2) LECTURE 9 BITG 1113: Array (Part 2) LECTURE 9 1 LEARNING OUTCOMES At the end of this lecture, you should be able to: 1. Describe the fundamentals of C-strings (character arrays) 2. Use C-string functions 3. Use

More information

Arrays. Arizona State University 1

Arrays. Arizona State University 1 Arrays CSE100 Principles of Programming with C++, Fall 2018 (based off Chapter 8 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona State University

More information

CS2255 HOMEWORK #1 Fall 2012

CS2255 HOMEWORK #1 Fall 2012 CS55 HOMEWORK #1 Fall 01 1.What is assigned to the variable a given the statement below with the following assumptions: x = 10, y = 7, and z, a, and b are all int variables. a = x >= y; a. 10 b. 7 c. The

More information

Getting started with C++ (Part 2)

Getting started with C++ (Part 2) Getting started with C++ (Part 2) CS427: Elements of Software Engineering Lecture 2.2 11am, 16 Jan 2012 CS427 Getting started with C++ (Part 2) 1/22 Outline 1 Recall from last week... 2 Recall: Output

More information

EP241 Computing Programming

EP241 Computing Programming EP241 Computing Programming Topic 4 Loops Department of Engineering Physics University of Gaziantep Course web page www.gantep.edu.tr/~bingul/ep241 Sep 2013 Sayfa 1 Introduction Loops are control structures

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 4: Control Structures I (Selection) Control Structures A computer can proceed: In sequence Selectively (branch) - making

More information

Programming Language. Functions. Eng. Anis Nazer First Semester

Programming Language. Functions. Eng. Anis Nazer First Semester Programming Language Functions Eng. Anis Nazer First Semester 2016-2017 Definitions Function : a set of statements that are written once, and can be executed upon request Functions are separate entities

More information

Computer Programming. Basic Control Flow - Loops. Adapted from C++ for Everyone and Big C++ by Cay Horstmann, John Wiley & Sons

Computer Programming. Basic Control Flow - Loops. Adapted from C++ for Everyone and Big C++ by Cay Horstmann, John Wiley & Sons Computer Programming Basic Control Flow - Loops Adapted from C++ for Everyone and Big C++ by Cay Horstmann, John Wiley & Sons Objectives To learn about the three types of loops: while for do To avoid infinite

More information

Principles of Programming. Chapter 6: Arrays

Principles of Programming. Chapter 6: Arrays Chapter 6: Arrays In this chapter, you will learn about Introduction to Array Array declaration Array initialization Assigning values to array elements Reading values from array elements Simple Searching

More information

Multiple Choice (Questions 1 14) 28 Points Select all correct answers (multiple correct answers are possible)

Multiple Choice (Questions 1 14) 28 Points Select all correct answers (multiple correct answers are possible) Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program

More information

3/12/2018. Structures. Programming in C++ Sequential Branching Repeating. Loops (Repetition)

3/12/2018. Structures. Programming in C++ Sequential Branching Repeating. Loops (Repetition) Structures Programming in C++ Sequential Branching Repeating Loops (Repetition) 2 1 Loops Repetition is referred to the ability of repeating a statement or a set of statements as many times this is necessary.

More information

Lab # 02. Basic Elements of C++ _ Part1

Lab # 02. Basic Elements of C++ _ Part1 Lab # 02 Basic Elements of C++ _ Part1 Lab Objectives: After performing this lab, the students should be able to: Become familiar with the basic components of a C++ program, including functions, special

More information

7.1. Chapter 7: Arrays Hold Multiple Values. Array - Memory Layout. Array Terminology. Array Terminology

7.1. Chapter 7: Arrays Hold Multiple Values. Array - Memory Layout. Array Terminology. Array Terminology Chapter 7: Arrays 7.1 Arrays Hold Multiple Values Copyright 2009 Pearson Education, Inc. Copyright Publishing as Pearson 2009 Addison-Wesley Pearson Education, Inc. Publishing as Pearson Addison-Wesley

More information