LAB SESSION ONE DIMENSIONAL ARRAY.

Slides:



Advertisements
Similar presentations
A Short Review Arrays, Pointers and Structures. What is an Array? An array is a collection of variables of the same type and placed in memory contiguously.
Advertisements

1 Arrays An array is a special kind of object that is used to store a collection of data. The data stored in an array must all be of the same type, whether.
Lab 8 User Defined Function.
Chapter 3. Expressions and Interactivity CSC125 Introduction to C++
Sample Theoretical Question What’s printed on the screen when the following programs are run? printing.c change_val.c And what does this function do? secret.c.
START DEFINITIONS values (3) N1 = (8, 1,-9) i N1 average N3,2 sum N2 = 0 temp N1 Do not guess or assume any values! Follow the values of the variables.
实验11.28.
Need for Arrays Exercise Read the IDs and the grades for all ICS 101 students. Compute and print the average of the students. Print the grades and IDs.
Review. In this lecture we will review and fill in loose ends regarding… Variables and how to name them Floating point data types Deciding what type to.
Case studies over control structures and iterative structures Instructor – Gokcen Cilingir Cpt S 121 (July 6, 2011) Washington State University.
1 11/05/07CS150 Introduction to Computer Science 1 Functions Chapter 6, page 303.
Display a 12-Month Calendar CS-2301 D-term Programming Assignment #2 12-Month Calendar CS-2301 System Programming C-term 2009 (Slides include materials.
1 Lab Session-8 CSIT-121 Fall 2003 w Call by Reference w Lab Exercise 1 w Lab Exercise for Demo w Practice Problems.
11.3 Function Prototypes A Function Prototype contains the function’s return type, name and parameter list Writing the function prototype is “declaring”
1 Lab Session-1 CSIT221 Spring 2003 b Group Programming Challenge b Individual Lab Exercise (Demo Required)
COMP 14 Introduction to Programming Mr. Joshua Stough February 21, 2005 Monday/Wednesday 11:00-12:15 Peabody Hall 218.
1 Lab Session-3 CSIT221 Spring 2003 b Group Worksheet 3 Exercise (Demo Required) b No new lab demo will be assigned to allow you to focus on HW#1.
1 Session-15 CSIT 121 Spring 2006 Selection with Switch~Case Selection with Switch~Case Need an integer or character to test for Need an integer or character.
Arrays. A group of data with same type stored under one variable. It is assumed that elements in that group are ordered in series. In C# language arrays.
Starting Out with C++, 3 rd Edition 1 Chapter 9 – Pointers.
1 11/8/06CS150 Introduction to Computer Science 1 Arrays Chapter 8 page 477 November 13, 2006.
1 Lab Assignment#5 Due 12/7 A car can hold 12 gallons of gasoline and it can travel 360 miles without refuelling. Write a program the displays the trip.
1 Lab Session-6 CSIT-121 Spring 2005 Structured Choice The do~While Loop Lab Exercises.
Java vs. You.
1 Lab Session-7 CSIT-121 Fall Introducing Structured Choice 4 The do~While Loop 4 Lab Exercises.
LAB-10 1-D Array I Putu Danu Raharja Information & Computer Science Department CCSE - King Fahd University of Petroleum & Minerals.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Java Programming Practice.
Math – Getting Information from the Graph of a Function 1.
P6, M2, D2.
Looping While-continue.
XP 1 Excel Tables Purpose of tables – Process data in a group – Used to facilitate calculations – Used to enhance readability of output Types of tables.
1 Lab Session-8 CSIT-121 Spring 2005 Call by Reference Lab Exercise for Demo Practice Problems.
Program 6 Any questions?. System.in Does the opposite of System.out.
Crypto Project Sample Encrypted Data: –Turing: CS Public\CryptoProjectData Crypto_Short_Keys_P_U.out Crypto_Long_Keys_O_R.out Bonus +10 points on.
1. Definition and General Structure 2. Small Example 1 3. Simplified Structure 4. Short Additional Examples 5. Full Example 2 6. Common Error The for loop.
1 DATA STRUCTURES: LISTS. 2 LISTS ARE USED TO WORK WITH A GROUP OF VALUES IN AN ORGANIZED MANNER. A SERIES OF MEMORY LOCATIONS CAN BE DIRECTLY REFERENCED.
LAB SESSION 5 STRUCT WITH FUNCTION 1. QUESTION 1 Given a struct definition: struct athleteRec { char name[30]; int age; char IC_number[20]; int score_event1;
Array Cs212: DataStructures Lab 2. Array Group of contiguous memory locations Each memory location has same name Each memory location has same type a.
More While Loop Examples CS303E: Elements of Computers and Programming.
Synthesis ENGR 1181 MATLAB 11. Topics  No new material  Covers topics that will be on the Midterm 2 Exam MATLAB 01 – Program Design MATLAB 02 – Introduction.
Writing JavaScript Functions. Goals By the end of this unit, you should understand … How to breakdown applications into individual, re-usable modules.
Arrays Arrays in C++ An array is a data structure which allows a collective name to be given to a group of elements which all have.
EXERCISES for ALGORITHMS WRITING
A n = c 1 a n-1 + c2an-2 + … + c d a n-d d= degree and t= the number of training data (notes) The assumption is that the notes in the piece are generated.
CS161 Topic #16 1 Today in CS161 Lecture #16 Prepare for the Final Reviewing all Topics this term Variables If Statements Loops (do while, while, for)
Math – What is a Function? 1. 2 input output function.
Assignment statement and Arithmetic operation 1 The major part of data processing.
EXERCISE Arrays, structs and file processing. Question You own a pet store. You want to keep an inventory of all the pets that you have. Pets available.
Homework #1: C++ Basics, Flow of Control, and Function Basics By J. H. Wang Mar. 13, 2012.
Mean, Median, and Mode An Introduction to Data Management: Measures of Central Tendencies.
Homework #2: Functions and Arrays By J. H. Wang Mar. 24, 2014.
Homework #1: C++ Basics, Flow of Control, and Function Basics
Arrays. The array data structure Array is a collection of elements, that have the same data type Integers (int) Floating point numbers (float, double)
Chapter 8 Arrays. A First Book of ANSI C, Fourth Edition2 Introduction Atomic variable: variable whose value cannot be further subdivided into a built-in.
Count Controlled Loops (Nested) Ain’t no sunshine when she’s gone …
Data Types and Conversions, Input from the Keyboard If you can't write it down in English, you can't code it. -- Peter Halpern If you lie to the computer,
Functions Structured Programming. Topics to be covered Introduction to Functions Defining a function Calling a function Arguments, local variables and.
CS 141 Computer Programming 1 Branching Statements.
Arrays. Topics to be Covered... Arrays ◦ Declaration ◦ Assigning values ◦ Array manipulation using loops Multi-dimensional arrays ◦ 2D arrays ◦ Declaration.
CS1010: Programming Methodology
Irvine, Kip R. Assembly Language for x86 Processors 7/e, What's Next Linking to an External Library The Book's Link Library Stack Operations Defining.
For loop. Exercise 1 Write a program to have the user input three (3) numbers: (f)rom, (t)o, and (i)ncrement. Count from f to t in increments of i, inclusive.
1 CSC103: Introduction to Computer and Programming Lecture No 17.
For Friday Read No quiz Program 6 due. Program 6 Any questions?
Exercise 2 : Using for loop Repetition (loop) (1)control variable initialization (2)Test Conditon (3)Modification of control variable value order : (1)
For Monday Read WebCT quiz 18.
For Wednesday No new reading No quiz.
Suppose I want to add all the even integers from 1 to 100 (inclusive)
Aggregate Functions.
Algorithms For use in Unit 2 Exam.
Presentation transcript:

LAB SESSION ONE DIMENSIONAL ARRAY

Question 1 (edited FROM csc 128 march 2012 exam paper) Compass is currently holding a charity car wash for a week. You are asked to write a program that calculates and displays the total collection, the average collection, and the minimum and maximum collection for the week. Thus, create an array of floating point of size SEVEN (7) to store the total collection per day from Monday through Sunday. Sample input and output as below:

QUESTION 2 (taken FROM csc 128 okt 2012 exam paper)

Question 3 (taken FROM csc 128 sept 2011 exam paper) Write a program that accepts any number of integers from the user in the range of 1 to 50 only. Only numbers in the range 1 to 50 should be stored in an array. The maximum size of the array is 100. Calculate the sum of the integers in the array and display the result. Assume the input ends when -1 is encountered.