1 Lab Session-11 CSIT 121 Fall 2003 Using arrays in functions Programming Exercise.

Slides:



Advertisements
Similar presentations
UNIT IV.
Advertisements

Introduction to C Programming
1 Business 90: Business Statistics Professor David Mease Sec 03, T R 7:30-8:45AM BBC 204 Lecture 5 = More of Chapter “Presenting Data in Tables and Charts”
Arrays. Topics Tables of Data Arrays – Single Dimensional Parsing a String into Multiple Tokens Arrays - Multi-dimensional.
1 Lab Session-1 CSIT221 Fall 2002 b Refresher slides b Practice Problem b Lab Exercise (Demo Required)
1 Session-17 CSIT 121 Spring 2006 Loops: Conditional and Count Controlled Loops: Conditional and Count Controlled LCV: Initialize; Test and Update LCV:
1 Lab Session-VI CSIT-120 Fall 2000 Let us look at C++ syntax rules in brief Next, we complete the lab session-V Lab session-VI deals with functions (OPTIONAL)
1 Session-16 CSIT 121 Spring 2006 Demo for switch-case due now Demo for switch-case due now String comparison String comparison Slide 23; sample case.
1 Lab Session-2 CSIT221 Spring 2003 b Intro to Object Oriented Programming b Practice Problem b Lab Exercise (Demo Required)
1 Lab Session-8 CSIT-121 Fall 2003 w Call by Reference w Lab Exercise 1 w Lab Exercise for Demo w Practice Problems.
1 Session-23 CSIT 121 Spring 2006 Revision Ch 7: Reference Parameters Revision Ch 7: Reference Parameters Chapter 8: Value Returning Functions Chapter.
1 Lab Session-9 CSIT221 Fall 2002 Lab Exercise Based on operator overloading (Demo Required)
1 Lab Session-1 CSIT221 Spring 2003 b Group Programming Challenge b Individual Lab Exercise (Demo Required)
1 Pre-Exam Class CSIT121 Fall 2000 Exam-II (Final Examination) TUESDAY DECEMBER 19th 8:30AM.
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-7 CSIT 121 Spring 2006 Lab Demo of NiMo Lesson 3-2 Exercises 1,2,3,4,5,6 (Arithmetic Operators with Program ‘Convert.cpp’) Q&A about operators.
1 Lab Session-4 CSIT121 Fall 2004 Scope of Variables Top Down Design Problem The Solution Lab Exercise for Demo.
1 Lab Session-5 CSIT221 Spring 2003 Default and Parameterized Constructors Destructors Programming Exercise for building a template based class (demo required)
1 Session-11 CSIT 121 Spring 2006 Test-1 is on March 9 th ; Demo-4 due Now Chapter 4 topics –Using get and ignore to control input data (3-19) –Prompting.
1 Lab Session-7 CSIT-121 Fall Revising Structured Choice 4 The While Loop variations 4 Lab Exercises.
1 Lab Session-3 CSIT121 Fall 2003 Some Questions Scope of Variables Top Down Design Problem The Solution Lab Exercise for Demo.
1 Business 90: Business Statistics Professor David Mease Sec 03, T R 7:30-8:45AM BBC 204 Lecture 6 = More of Chapter “Presenting Data in Tables and Charts”
1 Lab Session-6 CSIT-121 Spring 2005 Structured Choice The do~While Loop Lab Exercises.
Chapter 5 - Arrays CSC 200 Matt Kayala 2/27/06. Learning Objectives  Introduction to Arrays  Declaring and referencing arrays  For-loops and arrays.
1 Lab Session-3 CSIT 121 Fall 2004 Section-3 should finish Lab-1 Exercise first Division rules Operator precedence rules Lab Exercise.
1 Lab Session-9 CSIT-121 Fall 2003 w Random Number Generation w Designing a Game.
1 Lab Session-3 CSIT 121 Spring’05 Division rules Operator precedence rules Lab Exercise.
1 Lab Session-7 CSIT-121 Fall Introducing Structured Choice 4 The do~While Loop 4 Lab Exercises.
1 Session-9 CSIT 121 Spring 2006 Lab Demo (first 20 minutes) The correct way to do the previous lab sheet Function calls Calling void functions Calling.
1 Lab Session-XII CSIT121 Spring 2002 b Arrays and Their Usage b Finding the largest element b Lab Exercise 12-A b Lab Demo (12-B) b Practice Problems.
1 Lab Session-IX CSIT121 Fall 2000 w Arrays and Their Usage w Examples and Lab Exercises w Passing Arrays to Functions w Examples and Exercises w Sorting.
1 Lab Session-VIII CSIT-121 Spring 2002 w Formatted Output w Call by Reference w Lab Exercises w File Handling w Lab Exercises.
1 Lab Session-3 CSIT221 Fall 2002 b Exception Handling b Lab Exercise (Demo Required)
1 Lab Session-12 CSIT121 Fall 2004 Structures and Their Usage Passing Struct Variables to Functions.
Using the Frequencies Procedure in SPSS 9.0 for Windows © by Julia Hartman © Copyright 2000, Julia Hartman.
1.  Collections are data structures that holds data in different ways for flexible operations  C# Collection classes are defined as part of the ◦ System.Collections.
1 Lab Session-III CSIT-120 Fall 2000 Revising Previous session Data input and output While loop Exercise Limits and Bounds Session III-B (starts on slide.
1 Lab Session-8 CSIT-121 Spring 2005 Call by Reference Lab Exercise for Demo Practice Problems.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
C Lecture Notes 1 Arrays Lecture 6. C Lecture Notes 2 6.1Introduction Arrays –Structures of related data items –Static entity – same size throughout program.
 Introduction to Computer Science COMP 51 – Fall 2012 – Section 2 Structures.
An Introduction to Programming with C++ Sixth Edition Chapter 14 Sequential Access Files.
Creating fields in FlexiDATA Enter a title for your data file. Different types of field Different types of data validation.
1 Chapter 7 Arrays. 2 Topics 7.1 Arrays Hold Multiple Values 7.2 Accessing Array Elements 7.3 No Bounds Checking in C Array Initialization 7.5 Processing.
CSCI 171 Presentation 6 Functions and Variable Scope.
Copyright 2004 Scott/Jones Publishing Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 8 Arrays.
Slide 1 Chapter 5 Arrays. Slide 2 Learning Objectives  Introduction to Arrays  Declaring and referencing arrays  For-loops and arrays  Arrays in memory.
Chapter 5 Arrays. Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 5-2 Learning Objectives  Introduction to Arrays  Declaring and referencing.
Copyright © 2002 W. A. Tucker1 Chapter 9 Lecture Notes Bill Tucker Austin Community College COSC 1315.
An Introduction to Programming with C++ Sixth Edition Chapter 10 Void Functions.
Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Today: –Review declaration, implementation, simple class structure. –Add an exception class and show.
 2000 Prentice Hall, Inc. All rights reserved. 1 Chapter 4 - Arrays Outline 4.1Introduction 4.2Arrays 4.3Declaring Arrays 4.4Examples Using Arrays 4.5Passing.
L what is a void-function? l what is a predicate? how can a predicate be used? l what is program stack? function frame? l what’s call-by-value? l what’s.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Arrays + Functions Outline 6.5Passing Arrays to Functions.
1 C++ Data Types structured array struct union class address pointer reference simple integral enum char short int long bool floating float double long.
Chapter 7: Arrays. 7.1 Arrays Hold Multiple Values.
1 iLab-web guide to viewing Pathology results Click on icon for general pathology Click on icon for histopathology and diagnostic cytology.
Beginning C for Engineers Fall 2005 Arrays, 2-D arrays, character strings Bettina Schimanski Lecture 5: Section 2 (9/28/05) Section 4 (9/29/05)
L what is a void-function? l what is a boolean function? l is it possible for a function to have no parameters? l what is program stack? function frame?
Representing Variability with Mean, Median, Mode, and Range
Chapter 6 Arrays Lecturer: Mrs Rohani Hassan
Statistical Analysis with Excel
Programmer-Defined Functions, Call-by-Value, Multiple Files Lab 5
New Structure Recall “average.cpp” program
Lab Session-9 CSIT-121 Spring 2005
Previous Lecture Review
COURSE 3 LESSON 10-1 Displaying Frequency
Please send any images as a separate file
PLEASE ADD YOUR TITLE HERE.
Chapter 2 Excel Extension: Now You Try!
Presentation transcript:

1 Lab Session-11 CSIT 121 Fall 2003 Using arrays in functions Programming Exercise

2 Using Arrays in Functions By default, arrays are passed by reference to functions In order to protect the arrays, we add the keyword const before the data type in the prototype and heading of the function In the calling program,name of the array is used as the argument and in prototype and heading, we add a blank pair of square brackets after the array name We must send the size of the array or the number of elements to be processed to the function

3 Programming Exercise Due Sec1 Nov 18 th, Sec2 Nov 20 th A professor has requested development of “exam score analysis” software. Scores will be entered by the user within a function for 16 students. All the scores are in the range of 0 through 10. Your program should call a function to count the frequency of occurrence of each score and record it in a frequency array. A separate function should be used to compute the class mean and mode scores.Finally, a function is called to send all the scores, histogram, mean and mode to a file.

4 Programming Exercise Due Sec1 Nov 18 th, Sec2 Nov 20 th Please note that All the results are recorded in a text file You must use switch~case for multiple choices Do not use any global variables except for the constant definition lines #define CSIZE 16 and #define FREQ 11 so that you do not have to send the array sizes separately Use void functions You should initialize frequency array to zeroes You must develop a multi-file project

5 Programming Exercise Following are the contents of the result file: Scores of all 16 students Histogram (Bar chart) for frequencies of all the scores Mean and Mode scores

6 Sample Results Following are the sample scores to test your program:

7 Sample Results Following are the contents of “results.txt” file: Following are the scores Student ID#: 1 Scored 2 Points Student ID#: 2 Scored 5 Points Student ID#: 3 Scored 3 Points Student ID#: 4 Scored 8 Points Student ID#: 5 Scored 2 Points Student ID#: 6 Scored 3 Points Student ID#: 7 Scored 7 Points Student ID#: 8 Scored 2 Points Student ID#: 9 Scored 9 Points Student ID#: 10 Scored 10 Points Student ID#: 11 Scored 5 Points Student ID#: 12 Scored 9 Points Student ID#: 13 Scored 4 Points Student ID#: 14 Scored 3 Points Student ID#: 15 Scored 2 Points Student ID#: 16 Scored 0 Points

8 Sample Results The class mean score is: The most repeated score is: 2 Here is the Histogram of Class Performance Each Numerical Score is Followed on its Line by its Bar Chart ________________________________________ 0:* 1: 2:**** 3:*** 4:* 5:** 6: 7:* 8:* 9:** 10:*

9 Demo Check Points Multi-file project Switch~Case for frequency count No global variables Results file contents match the sample results shown on slides 7 and 8 (If any of the above is not fulfilled, project demo is recorded as “Partial”)