Homework #2: Functions and Arrays

Slides:



Advertisements
Similar presentations
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.
Advertisements

Review BP Dari slide pak cahyo pertemuan 7 dan pertemuan 2 dengan sedikit modifikasi.
1 Various Methods of Populating Arrays Randomly generated integers.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 7- 1 Overview 7.1 Introduction to Arrays 7.2 Arrays in Functions 7.3.
CS102--Object Oriented Programming Discussion 2: (programming strategy in java) – Two types of tasks – The use of arrays Copyright © 2008 Xiaoyan Li.
实验11.28.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 14 – Student Grades Application: Introducing.
Computer Science 1620 Functions. Given a number n, the factorial of n, written n!, is computed as follows: note: 0! = 1 examples: n! = n x (n-1) x (n-2)
Computer Science 1620 Variables and Memory. Review Examples: write a program that calculates and displays the average of the numbers 45, 69, and 106.
1 ICS102: Introduction To Computing King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science.
Computer Science 1620 Programming & Problem Solving.
1 ICS103 Programming in C Lecture 12: Arrays I. 2 Outline Motivation for One-dimensional Arrays What is a One-dimensional Array? Declaring One-dimensional.
Arrays.
Lesson 3-6 Compound Inequalities Part 2 August 25, 2014.
CMSC 104, Version 8/061L22Arrays1.ppt Arrays, Part 1 of 2 Topics Definition of a Data Structure Definition of an Array Array Declaration, Initialization,
Chapter 6: Functions.
1 Project 5: Median. 2 The median of a collection of numbers is the member for which there are an equal number less than or equal and greater than or.
Loop Exercise 1 Suppose that you want to take out a loan for $10,000, with 18% APR, and you're willing to make payments of $1,200/month. How long will.
C++ Arrays. Agenda What is an array? What is an array? Declaring C++ arrays Declaring C++ arrays Initializing one-dimensional arrays Initializing one-dimensional.
Agenda  Commenting  Inputting Data from Keyboard (scanf)  Arithmetic Operators  ( ) * / + - %  Order of Operations  Mixing Different Numeric Data.
First tutorial.
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.
EGR 2261 Unit 8 One-dimensional Arrays  Read Malik, pages in Chapter 8.  Homework #8 and Lab #8 due next week.  Quiz next week.
Proposal for Term Project J. H. Wang Mar. 2, 2015.
Homework #3: Classes and Constructors
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2009 Pearson Education, Inc., Upper.
Homework #4: Operator Overloading and Strings By J. H. Wang May 8, 2012.
DATA STRUCTURES LAB 1 TA: Nouf Al-harbi
Value and Reference Parameters. CSCE 1062 Outline  Summary of value parameters  Summary of reference parameters  Argument/Parameter list correspondence.
IR Homework #2 By J. H. Wang Mar. 31, Programming Exercise #2: Query Processing and Searching Goal: to search relevant documents for a given query.
 Introduction to Computer Science COMP 51 – Fall 2012 – Section 2 Structures.
Writing JavaScript Functions. Goals By the end of this unit, you should understand … How to breakdown applications into individual, re-usable modules.
19&20-2 Know how to declare pointer variables. Understand the & (address) and *(indirection) operators. Dynamic Memory Allocation Related Chapter: ABC.
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)
1 Flight Times. 2 Problem Specification 3 Additional Specifications You may assume that the input is a valid 24 hour time. Output the time entered by.
IR Homework #1 By J. H. Wang Mar. 16, Programming Exercise #1: Vector Space Retrieval - Indexing Goal: to build an inverted index for a text collection.
Homework #2: Functions and Arrays By J. H. Wang Mar. 20, 2012.
Lab 6 (2) Arrays ► Lab 5 (1) Exercise Review ► Array Concept ► Why Arrays? ► Array Declaration ► An Example of Array ► Exercise.
Homework #1: C++ Basics, Flow of Control, and Function Basics By J. H. Wang Mar. 13, 2012.
1 One Dimensional Arrays Chapter 11 2 "All students to receive arrays!" reports Dr. Austin. Declaring arrays scores :
Homework #4: Operator Overloading and Strings By J. H. Wang Apr. 17, 2009.
Function Overloading Two different functions may have the same name as long as they differ in the number or types of arguments: int max(int x, int y) and.
Homework #2: Functions and Arrays By J. H. Wang Mar. 24, 2014.
Homework #1: C++ Basics, Flow of Control, and Function Basics
Programming Fundamentals I Java Programming Spring 2009 Instructor: Xuan Tung Hoang TA: Tran Minh Trung Lab 03.
Homework #3: Classes and Constructors By J. H. Wang Apr. 14, 2014.
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.
Functions Structured Programming. Topics to be covered Introduction to Functions Defining a function Calling a function Arguments, local variables and.
1 Project 2: Using Variables and Expressions. 222 Project 2 Overview For this project you will work with three programs Circle Paint Ideal_Weight What.
Computer Programming for Engineers
Searching CSE 103 Lecture 20 Wednesday, October 16, 2002 prepared by Doug Hogan.
IR Homework #1 By J. H. Wang Mar. 25, Programming Exercise #1: Indexing Goal: to build an index for a text collection using inverted files Input:
Homework #3: Classes and Constructors
Homework #3: Classes and Constructors By J. H. Wang Apr. 24, 2015.
CPSC 233 Tutorial 5 February 9 th /10 th, Java Classes Each Java class contains a set of instance variables and methods Instance Variables: Type.
Lab 9 Exercises.
Building Programs from Existing Information Solutions for programs often can be developed from previously solved problems. Data requirements and solution.
Homework #4: Operator Overloading and Strings By J. H. Wang May 22, 2015.
General Condition Loop A general condition loop just loops while some condition remains true. Note that the body of the loop should (eventually) change.
Arrays Chap. 9 Storing Collections of Values 1. Introductory Example Problem: Teachers need to be able to compute a variety of grading statistics for.
8.1 – Sequences and Series. Sequences Infinite sequence = a function whose domain is the set of positive integers a 1, a 2, …, a n are the terms of the.
User-Written Functions
Big Data Analytics: HW#3
Arrays Part-1 Armen Keshishian.
IPC144 Introduction to Programming Using C Week 2 – Lesson 1
IPC144 Introduction to Programming Using C Week 8 – Lesson 1
IPC144 Introduction to Programming Using C Week 6 – Lesson 1
Arrays, Part 1 of 2 Topics Definition of a Data Structure
Presentation transcript:

Homework #2: Functions and Arrays By J. H. Wang Mar. 24, 2015

Programming Exercises Your time machine is capable of going forward in time up to 24 hours. The machine is configured to jump ahead in minutes. To enter the proper number of minutes into your machine, you would like a program that can take a start time and an end time and calculate the difference in minutes between them, The end time will always be within 24 hours of the start time. Use military notation for both the start and end time (e.g., 0000 for midnight and 2359 for one minute before midnight). [… to be continued on the next slide…]

[… continued from the previous slide …] Write a function that takes as input a start time and an end time represented as an int, using military notation. The function should return the difference in minutes as an integer. Write a C++ program that calls your function with times entered by the user. (Hint: Be careful of time intervals that start before midnight and end the following day.)

The standard deviation of a list of numbers is a measure of how much the numbers deviate from the average. If the standard deviation is small, the numbers are clustered close to the average. If the standard deviation is large, the numbers are scattered far from the average. The standard deviation, S, of a list of N numbers xi is defined as follows, where x(bar) is the average of the N numbers x1, x2, …. [… to be continued on the next slide …]

[… continued from the previous slide …] Define a function that takes a partially filled array of numbers as its argument and returns the standard deviation of the numbers in the array. Since a partially filled array requires two formal parameters: an array parameter and a formal parameter of type int that gives the number of array positions used. The numbers in the array will be of type double. Embed your function in a suitable C++ test program.

Use a one-dimensional array to solve the following problem Use a one-dimensional array to solve the following problem. Write a function to check if a given array of integers contains a duplicate with other numbers in the array. Then, the function should store only the unique values into another array as an array parameter. Also, the number of unique values has to be returned via a call-by-reference parameter. (a) Write a C++ program that allows the user to test the function, and display the output of the array after duplicate elimination. (b) Suppose the integers represent scores between 0 and 100, inclusive. Please design a more efficient function to do the duplicate elimination, and test the function in your program.

Homework Submission Due: 2 weeks (Apr. 17, 2015) Submission instructions: http://mslin.ee.ntut.edu.tw/ File names: Please name your file according to our homework. For example, <id>_HW1.zip or <id>_quiz2.rar

Questions or Comments?