COP 3014: Fall 2017 Homework 4
|
|
- Megan Wilkinson
- 5 years ago
- Views:
Transcription
1 COP 3014: Fall 2017 Homework 4 Total Points: 200 Due: Wednesday 11/01/ Objective The objective for this assignment is to make sure You understand and can work with C++ arrays. You are comfortable with writing functions in C++. You are familiar with repetitive structures (loops) and selection statements (if/else or switch) in any combination and can use them in functions and to manipulate array data. You can approach a complex problem, break it down into various parts, and put together a solution. From this assignment, please make sure you conform to Output requirements. You should now be familiar enough with cout statements and output formatting that you should be able to EXACTLY match the sample output (other than certain exceptions you will be informed about beforehand). This assignment requires you to several files on Canvas. Please do so in a SINGLE submission. Canvas allows you to turn in multiple flies in one submission. Once you have uploaded your first file, click attach another file to upload your second file and so on. Turn in your 3 files functions.cpp, arrays.cpp and matrix.cpp, (and the extra credit program evaluate.cpp, if you are attempting it) to Canvas. 2 Program 1 - Writing Functions - 75 points Squilliam Fancyson has heard of the fancy calculator that Squidward (supposedly) made for the Krusty Krab s Cash Register. Determined to prove that he is the best programmer in town, he has challenged Squidward to a series of programming challenges. If Squilliam wins, Squidward has to hand over his clarinet and never paint again. If Squidward wins, Squilliam will work Squidward s shift at the Krusty Krab s cash register for a week. Squidward is determined to win, except he is not really a programmer. He has left no stone (pioneer transport or otherwise) unturned. He has even tried asking Karen, who was unable to help. He realizes that instead of working off Mr. Krabs old computer (the one Patrick smashed while painting the house), he could just pay you off to do the challenges for him. Your task today is to help Squidward retain his sanity and dignity (whatever is left of it). The first challenge is to write a few mathematical functions. For this program, we define a new term called Special Difference. The Special Difference of a number is the difference between the number and the one you obtain by reversing its digits. For example, the Special Difference of 1234 is 3087 ( ). 1
2 We also find the value of e x using the Taylor s series expansion. The Taylor s Series expansion of e x is defined as inf x n n! = x0 0! + x1 1! + x2 2! + x3 3!... n=0 Please make sure your program conforms to the following requirements. 1. Write a function called reverse that takes a number as a parameter and returns the reversed number. (20 points) 2. Write a function called difference that accepts a number as a parameter, calculates the special difference of the number and returns it. (15 points) 3. Write a function called factorial that returns the factorial of a number. You can use the code from the class examples. 4. Write a function called sum that takes x and a number n as a parameter and calculates e x accurate to the nth term. (20 points) 5. You can use the pow function to calculate x n. 6. In the main function, accept a series of numbers from the user. Stop if the number entered is negative. Use the difference method to find the sum of the special differences and print it. (10 points) 7. Next, still in the main function, accept the values of x and n from the user and use the sum function to calculate the required value and print it. (5 points) 8. Make sure you add comments to explain your logic. (5 points) 2.1 Sample Run Calculating the Special Differences: Enter the numbers: The Sum is 4095 Calculating e^x through Taylor s Series Expansion: Enter the value of x: 5 Enter the number of terms: 20 e^x is Program 2 - Array Operations - 75 Points Squilliam has been soundly beaten in the first challenge. He still refuses to give in. It is now a best of 3 challenge. The next item on the agenda is array operations. For this program, we re going to perform a range of standard array operations to show Squilliam once and for all, that Squidward is familair with arrays and how they work. You re required to write functions to insert and delete elements from an array, and sort the array. We re also going to write a command line menu to do 2
3 these tasks repeatedly. For this problem, you can assume that the array size will never drop below 1 and will never rise above 99. Please make sure you conform to the following requirements: 1. Create a global constant integer called CAPACITY and set it to 100 (5 points) 2. Use the class examples and exercises to write functions to initialize the array by reading values from the user, and to print the array. These functions take the array and its current size as parameters. You can use the code in the examples. (5 points) 3. Write a function called insert that takes the array, a number, a position and the current size of the array as parameters. Insert the number at the given position. (15 points) 4. Write a function called remove that takes the array, a number and the current size of the array, and removes the first instance of the number from the array. (15 points) 5. Write a function called sort that takes the array and its current size as parameters and sorts the array in ascending order. You need to use insertion sort, which is given below. (15 points) 6. In the main function, have the user initialize the array. Then, write a command line menu with the following options: Print Insert Remove Sort Exit Call the appropriate functions when the user chooses a particular option. Print and error message and continue if the user enters a wrong option. (15 points) 7. Please make sure your code is appropriately commented. (5 points) Algorithm for insertion sort loop i from 1 to Length(A) x = A[i] j = i - 1 loop as long as j >= 0 and A[j] > x A[j+1] = A[j] j = j - 1 end loop A[j+1] = x end loop 3.1 Sample Runs Enter the number of elements you want to enter (Max 100): 5 Enter 5 numbers
4 Enter your option: 1 Enter the number: 3.1 Enter the position: 2 Element Inserted. Enter your option: 3 The array is: Enter your option: 4 Enter your option: 3 The array is: Enter your option: 2 Enter the element: 0.8 Element deleted. Enter your option: 3 The array is:
5 Enter your option: 5 Goodbye! 4 Program 3 - Matrix Norms - 50 points The competition is heating up. The special judging panel, consisting of Karen, Old Man Jenkins and Sandy, do not want to release the results of the previous challenge until this one is complete as well. For this challege, you have to compute the Forbenius Norm of a matirx. The Forbenius norm of a matrix is defined as square root of the sum of the squares of all the elements of a matrix. Write a C++ program to compute the Forbenius norm. Please make sure you conform to the following requirements: 1. Declare global constant integers for ROWCAP and COLCAP. Set both to 100 (5 points) 2. Use the class examples and exercises to write functions to initialize the matrix by reading values from the user, and to print the matrix. These functions take the matrix and its current number of rows and columns as parameters. You can use the code in the examples. (5 points) 3. Write a function called findnorm that accepts the matrix, its current number of rows and columns and return its Forbenius norm. (20 points) 4. In the main function, initialize the matrix, read in its values and compute and print its norm. (15 points) 5. Please make sure your code is commented (5 points). 4.1 Sample Run Enter the number of rows: 3 Enter the number of columns: 3 Enter the matrix: The Forbenius Norm is: Extra Credit Problem - Simple Calculator - 50 points In the distant and slightly dystopian future, the Grand Poobah has banned the use of hand held calculators. Some say he was hit on the head with one. Others believe it is due to his fear of accountants. Either way, hand calculators are a thing of the past. However, you find yourself in sudden need of a calculator that can perform simple calculations. No worries. You are a C++ programmer and you can write a console application to do this. This program does not serve any practical purpose and is, in fact, a very inefficient way to design a calculator. This exercise is just to give you some practice in writing functions. 5
6 Specifications This program makes use of functions. The main function should only contain one line, which is a call to the evaluate function. (5 points). Write 5 functions to perform the 5 basic arithmetic operations: +, -, *, / and %. Give them some sensible name (for example, the function that performs addition can be called add). Each of the functions will take 2 integer arguments and return an integer value. (25 points) Write a function called evaluate, that does not take any arguments and does not return a value. This method will read in an arbitrary number of values from the user: an integer followed by a character that denotes an operation. Once you have the number and the operation, call the appropriate function from the five that you just wrote to keep a running evaluated total. The user input ends when the character entered is a?. When the user is done with input, print the result. (15 points) You may assume that all inputs are valid. You need not test for wrong inputs. Here, you need to ignore the order of operations and calculate the values as they come. Please include comments wherever appropriate. (5 points) 5.1 Sample Run Enter the expression: * 2 % 19 / 5? The result is Sample Run 2 Enter the expression: 12 * ? The result is 63 6 Generic Guidelines 1. Include the header comment with your name and other information on the top of your files. 6
7 2. Please make sure you re only using the concepts already discussed in class. That is, please try and restrict yourself to input/output statements, variables, selection statements, loops, functions and arrays. Using any other concept (like pointers) will result in loss of points. 3. You cannot use arrays for Problem 1 and Problem 4. For those, you are restricted to function, loops and selection statements. 4. The first 2 programs are worth 75 points each. the third program is worth 50 points. 5. Please make sure that you re conforming to specifications (program name, print statements, expected inputs and outputs etc.). 6. No global variables (variables outside of main() ) 7. All input and output must be done with streams, using the library iostream 8. You may only use the iostream, iomanip and the cmath libraries (you do not need any others for these tasks) 9. Your program should only use standard ANSI header files (make sure to follow the directions exactly on the handout for creating Visual C++ projects, so that Windows-specific headers like stdafx.h and conio.h are not placed into your file) 10. NO C style printing is permitted. (Aka, dont use printf). Use cout if you need to print to the screen. 11. When you write source code, it should be readable and well-documented (comments). 12. Make sure you either develop with or test with MS Visual C /2015/2017 (to be sure it reports no compile errors or warnings!) before you submit the program. 13. Program submissions should be done through the Canvas class page, under the assignments tab (if its not there yet Ill create it soon.) Do not send program submissions through attachments will not be accepted as valid submissions. 14. The ONLY files you will submit via Canvas are functions.cpp, arrays.cpp and matrix.cpp, (and the extra credit program evaluate.cpp, if you are attempting it). 15. Please make sure you ve compiled and run your program before you turn it in. Compilation errors can be quite costly. 16. General Advice - always keep an untouched copy of your finished homework files in your . These files will have a time-stamp which will show when they were last worked on and will serve as a backup in case you ever have legitimate problems with submitting files through Canvas. Do this for ALL programs. 7
COP 3014: Spring 2018 Homework 5
COP 3014: Spring 2018 Homework 5 Total Points: 100 Due: Friday 03/23/2018 1 Objective The objective for this assignment is to make sure You understand and can work with C++ arrays. You are comfortable
More informationCOP 3014 Honors: Spring 2017 Homework 5
COP 3014 Honors: Spring 2017 Homework 5 Total Points: 150 Due: Thursday 03/09/2017 11:59:59 PM 1 Objective The purpose of this assignment is to test your familiarity with C++ functions and arrays. You
More informationCOP 3014: Spring 2019 Homework 6
COP 3014: Spring 2019 Homework 6 Total Points: 200 (plus 50 points extra credit) Due: Thursday, 04/25/2018 11:59 PM 1 Objective The objective of this assignment is to make sure: You are familiar with dynamic
More informationTo practice overall problem-solving skills, as well as general design of a program
Programming Assignment 5 Due March 27, 2015 at 11:59 PM Objectives To gain experience with file input/output techniques To gain experience with formatting output To practice overall problem-solving skills,
More informationCarleton University Department of Systems and Computer Engineering SYSC Foundations of Imperative Programming - Winter 2012
Carleton University Department of Systems and Computer Engineering SYSC 2006 - Foundations of Imperative Programming - Winter 2012 Lab 2 - C Functions Objective The objective of this lab is to write some
More informationDue Date: Two Program Demonstrations (Testing and Debugging): End of Lab
CSC 111 Fall 2005 Lab 6: Methods and Debugging Due Date: Two Program Demonstrations (Testing and Debugging): End of Lab Documented GameMethods file and Corrected HighLow game: Uploaded by midnight of lab
More informationCS Exam 2 Study Suggestions
CS 131 - Fall 2009 p. 1 last modified: 11-10-09 CS 131 - * Remember: anything covered in lecture, in lab, or on a homework, is FAIR GAME. * You are responsible for all of the material covered through Week
More informationMore About WHILE Loops
More About WHILE Loops http://people.sc.fsu.edu/ jburkardt/isc/week04 lecture 07.pdf... ISC3313: Introduction to Scientific Computing with C++ Summer Semester 2011... John Burkardt Department of Scientific
More informationCONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics. COMP-202 Unit 1: Introduction
CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics COMP-202 Unit 1: Introduction Announcements Did you miss the first lecture? Come talk to me after class. If you want
More informationCS 356, Fall 2018 Data Lab (Part 1): Manipulating Bits Due: Wednesday, Sep. 5, 11:59PM
CS 356, Fall 2018 Data Lab (Part 1): Manipulating Bits Due: Wednesday, Sep. 5, 11:59PM 1 Introduction The purpose of this assignment is to become more familiar with bit-level representations of integers
More informationData Lab: Manipulating Bits
Data Lab: Manipulating Bits 1 Introduction The purpose of this assignment is to become more familiar with bit-level representations of integers and floating point numbers. You ll do this by solving a series
More informationProgramming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur
Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture 04 Programs with IO and Loop We will now discuss the module 2,
More informationCS 1044 Project 1 Fall 2011
Simple Arithmetic Calculations, Using Standard Functions One of the first things you will learn about C++ is how to perform numerical computations. In this project, you are given an incomplete program
More informationComputer Science C++ Placement Exam
Computer Science C++ Placement Exam The Computer Science Department now has available a placement exam for students who wish to demonstrate their competence in the material covered in the course CSCI C101
More informationCS 2505 Fall 2018 Data Lab: Data and Bitwise Operations Assigned: November 1 Due: Friday November 30, 23:59 Ends: Friday November 30, 23:59
CS 2505 Fall 2018 Data Lab: Data and Bitwise Operations Assigned: November 1 Due: Friday November 30, 23:59 Ends: Friday November 30, 23:59 1 Introduction The purpose of this assignment is to become more
More informationCS 1044 Program 6 Summer I dimension ??????
Managing a simple array: Validating Array Indices Most interesting programs deal with considerable amounts of data, and must store much, or all, of that data on one time. The simplest effective means for
More informationSpring CS Homework 12 p. 1. CS Homework 12
Spring 2018 - CS 111 - Homework 12 p. 1 Deadline 11:59 pm on Friday, May 4, 2018 Purpose CS 111 - Homework 12 To practice with sentinel- and question-controlled loops, file input and file output, and writing
More informationProgramming - 1. Computer Science Department 011COMP-3 لغة البرمجة 1 لطالب كلية الحاسب اآللي ونظم المعلومات 011 عال- 3
Programming - 1 Computer Science Department 011COMP-3 لغة البرمجة 1 011 عال- 3 لطالب كلية الحاسب اآللي ونظم المعلومات 1 1.1 Machine Language A computer programming language which has binary instructions
More informationCh. 11: References & the Copy-Constructor. - continued -
Ch. 11: References & the Copy-Constructor - continued - const references When a reference is made const, it means that the object it refers cannot be changed through that reference - it may be changed
More informationWelcome Back. CSCI 262 Data Structures. Hello, Let s Review. Hello, Let s Review. How to Review 8/19/ Review. Here s a simple C++ program:
Welcome Back CSCI 262 Data Structures 2 - Review What you learned in CSCI 261 (or equivalent): Variables Types Arrays Expressions Conditionals Branches & Loops Functions Recursion Classes & Objects Streams
More informationCIS 130 Exam #2 Review Suggestions
CIS 130 - Exam #2 Review Suggestions p. 1 * last modified: 11-11-05, 12:32 am CIS 130 Exam #2 Review Suggestions * remember: YOU ARE RESPONSIBLE for course reading, lectures/labs, and especially anything
More information11.3 Function Prototypes
11.3 Function Prototypes A Function Prototype contains the function s return type, name and parameter list Writing the function prototype is declaring the function. float square (float x); In a function
More informationPROGRAMMING IN C AND C++:
PROGRAMMING IN C AND C++: Week 1 1. Introductions 2. Using Dos commands, make a directory: C:\users\YearOfJoining\Sectionx\USERNAME\CS101 3. Getting started with Visual C++. 4. Write a program to print
More informationExcel Basics: Working with Spreadsheets
Excel Basics: Working with Spreadsheets E 890 / 1 Unravel the Mysteries of Cells, Rows, Ranges, Formulas and More Spreadsheets are all about numbers: they help us keep track of figures and make calculations.
More informationPointers. A pointer is simply a reference to a variable/object. Compilers automatically generate code to store/retrieve variables from memory
Pointers A pointer is simply a reference to a variable/object Compilers automatically generate code to store/retrieve variables from memory It is automatically generating internal pointers We don t have
More informationHomework 11 Program Setup (with some IMPORTANT NEW STEPS!)
Spring 2018 - CS 111 - Homework 11 p. 1 Deadline 11:59 pm on Friday, April 27, 2018 Purpose To practice with loops, arrays, and more! How to submit CS 111 - Homework 11 Submit your main.cpp (or it may
More informationCS Final Exam Review Suggestions - Spring 2014
CS 111 - Final Exam Review Suggestions p. 1 CS 111 - Final Exam Review Suggestions - Spring 2014 last modified: 2014-05-09 before lab You are responsible for material covered in class sessions, lab exercises,
More informationCS 2505 Fall 2013 Data Lab: Manipulating Bits Assigned: November 20 Due: Friday December 13, 11:59PM Ends: Friday December 13, 11:59PM
CS 2505 Fall 2013 Data Lab: Manipulating Bits Assigned: November 20 Due: Friday December 13, 11:59PM Ends: Friday December 13, 11:59PM 1 Introduction The purpose of this assignment is to become more familiar
More informationCMSC 201 Fall 2016 Homework 6 Functions
CMSC 201 Fall 2016 Homework 6 Functions Assignment: Homework 6 Functions Due Date: Wednesday, October 26th, 2016 by 8:59:59 PM Value: 40 points Collaboration: For Homework 6, collaboration is not allowed
More informationWelcome Back. CSCI 262 Data Structures. Hello, Let s Review. Hello, Let s Review. How to Review 1/9/ Review. Here s a simple C++ program:
Welcome Back CSCI 262 Data Structures 2 - Review What you learned in CSCI 261 (or equivalent): Variables Types Arrays Expressions Conditionals Branches & Loops Functions Recursion Classes & Objects Streams
More informationCS106X Handout 03 Autumn 2012 September 24 th, 2012 Getting Started
CS106X Handout 03 Autumn 2012 September 24 th, 2012 Getting Started Handout written by Julie Zelenski, Mehran Sahami, Robert Plummer, and Jerry Cain. After today s lecture, you should run home and read
More informationLocal and Global Variables
Lecture 10 Local and Global Variables Nearly every programming language has a concept of local variable. As long as two functions mind their own data, as it were, they won t interfere with each other.
More informationCarleton University Department of Systems and Computer Engineering SYSC Foundations of Imperative Programming - Winter 2012
Carleton University Department of Systems and Computer Engineering SYSC 2006 - Foundations of Imperative Programming - Winter 2012 Lab 3 - Arrays and Functions Objective The objective of this lab is to
More informationIntroduction to C++ Dr M.S. Colclough, research fellows, pgtas
Introduction to C++ Dr M.S. Colclough, research fellows, pgtas 5 weeks, 2 afternoons / week. Primarily a lab project. Approx. first 5 sessions start with lecture, followed by non assessed exercises in
More informationCSci 1113, Fall 2015 Lab Exercise 4 (Week 5): Write Your Own Functions. User Defined Functions
CSci 1113, Fall 2015 Lab Exercise 4 (Week 5): Write Your Own Functions User Defined Functions In previous labs, you've encountered useful functions, such as sqrt() and pow(), that were created by other
More informationData Lab: Manipulating Bits
Data Lab: Manipulating Bits 1 Introduction The purpose of this assignment is to become more familiar with bit-level representations of integers and floating point numbers. You ll do this by solving a series
More informationCS Homework 11 p. 1. CS Homework 11
CS 111 - Homework 11 p. 1 Deadline 11:59 pm on Monday, May 2, 2016 How to submit Each time you would like to submit your work: CS 111 - Homework 11 If your files are not already on nrs-labs, be sure to
More informationBIL220, Spring 2012 Data Lab: Manipulating Bits Assigned: Feb. 23, Due: Wed., Mar. 8, 23:59PM
BIL220, Spring 2012 Data Lab: Manipulating Bits Assigned: Feb. 23, Due: Wed., Mar. 8, 23:59PM Ali Caglayan (alicaglayan@cs.hacettepe.edu.tr) and Oguzhan Guclu (oguzhanguclu@cs.hacettepe.edu.tr) are the
More informationOperator overloading
1 Introduction 2 The copy constructor 3 Operator Overloading 4 Eg 1: Adding two vectors 5 The -> operator 6 The this pointer 7 Overloading = 8 Unary operators 9 Overloading for the matrix class 10 The
More informationComputer Programming C++ (wg) CCOs
Computer Programming C++ (wg) CCOs I. The student will analyze the different systems, and languages of the computer. (SM 1.4, 3.1, 3.4, 3.6) II. The student will write, compile, link and run a simple C++
More informationBasic memory model Using functions Writing functions. Basics Prototypes Parameters Return types Functions and memory Names and namespaces
Basic memory model Using functions Writing functions Basics Prototypes Parameters Return types Functions and memory Names and namespaces When a program runs it requires main memory (RAM) space for Program
More informationn! = 1 * 2 * 3 * 4 * * (n-1) * n
The Beauty and Joy of Computing 1 Lab Exercise 9: Problem self-similarity and recursion Objectives By completing this lab exercise, you should learn to Recognize simple self-similar problems which are
More informationDOMjudge team manual. Summary. Reading and writing. Submitting solutions. Viewing scores, submissions, etc.
judge DOMjudge team manual Summary /\ DOM DOM judge Here follows a short summary of the system interface. This is meant as a quick introduction, to be able to start using the system. It is, however, strongly
More informationTo become familiar with array manipulation, searching, and sorting.
ELECTRICAL AND COMPUTER ENGINEERING 06-88-211: COMPUTER AIDED ANALYSIS LABORATORY EXPERIMENT #2: INTRODUCTION TO ARRAYS SID: OBJECTIVE: SECTIONS: Total Mark (out of 20): To become familiar with array manipulation,
More informationAssignment #2: Intro to Java Due: 11AM PST on Wednesday, July 12
Nick Troccoli Assignment 2 CS 106A July 5, 2017 Assignment #2: Intro to Java Due: 11AM PST on Wednesday, July 12 This assignment should be done individually (not in pairs) Based on handouts by Mehran Sahami,
More informationCS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG
CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG 1 Notice Reading Assignment Chapter 1: Introduction to Java Programming Homework 1 It is due this coming Sunday
More informationCS Homework 10 p. 1. CS Homework 10
CS 111 - Homework 10 p. 1 Deadline 11:59 pm on Friday, December 2, 2016 How to submit Each time you would like to submit your work: CS 111 - Homework 10 If your files are not already on nrs-labs, be sure
More informationCS Final Exam Review Suggestions - Fall 2017
CS 111 - Final Exam Review Suggestions p. 1 CS 111 - Final Exam Review Suggestions - Fall 2017 last modified: 2016-12-09 You are responsible for material covered in class sessions, lab exercises, and homeworks;
More informationprintf( Please enter another number: ); scanf( %d, &num2);
CIT 593 Intro to Computer Systems Lecture #13 (11/1/12) Now that we've looked at how an assembly language program runs on a computer, we're ready to move up a level and start working with more powerful
More informationCSCI-1200 Data Structures Spring 2016 Lecture 6 Pointers & Dynamic Memory
Announcements CSCI-1200 Data Structures Spring 2016 Lecture 6 Pointers & Dynamic Memory There will be no lecture on Tuesday, Feb. 16. Prof. Thompson s office hours are canceled for Monday, Feb. 15. Prof.
More informationCSci 1113, Spring 2018 Lab Exercise 3 (Week 4): Repeat, Again and Again
CSci 1113, Spring 2018 Lab Exercise 3 (Week 4): Repeat, Again and Again Iteration Imperative programming languages such as C++ provide high-level constructs that support both conditional selection and
More informationCS Homework 11 p. 1. CS Homework 11
CS 111 - Homework 11 p. 1 Deadline 11:59 pm on Friday, December 12, 2014 How to submit Each time you would like to submit your work: CS 111 - Homework 11 IF they are not already on nrs-labs, then transfer/save
More informationECEn 424 Data Lab: Manipulating Bits
ECEn 424 Data Lab: Manipulating Bits 1 Introduction The purpose of this assignment is to become more familiar with bit-level representations of integers and floating point numbers. You ll do this by solving
More informationc) Comments do not cause any machine language object code to be generated. d) Lengthy comments can cause poor execution-time performance.
2.1 Introduction (No questions.) 2.2 A Simple Program: Printing a Line of Text 2.1 Which of the following must every C program have? (a) main (b) #include (c) /* (d) 2.2 Every statement in C
More informationWriting to and reading from files
Writing to and reading from files printf() and scanf() are actually short-hand versions of more comprehensive functions, fprintf() and fscanf(). The difference is that fprintf() includes a file pointer
More informationCMSC 201, Fall 2014 Data Lab: Manipulating Bits Assigned: Sept. 03, Due: Wed., Sept. 17, 11:59PM
CMSC 201, Fall 2014 Data Lab: Manipulating Bits Assigned: Sept. 03, Due: Wed., Sept. 17, 11:59PM This lab was written by Randy Bryant and David O Hallaron, the authors of our textbook. 1 Introduction The
More informationAssignment 3: Distance COP3330 Fall 2017
Assignment 3: Distance COP3330 Fall 2017 Due: Monday, October 16, 2017 at 11:59 PM Objective This assignment will provide experience with basic operator overloading. Task Your task will be to create a
More informationHomework #3 CS2255 Fall 2012
Homework #3 CS2255 Fall 2012 MULTIPLE CHOICE 1. The, also known as the address operator, returns the memory address of a variable. a. asterisk ( * ) b. ampersand ( & ) c. percent sign (%) d. exclamation
More informationCOMP 202 Java in one week
COMP 202 Java in one week... Continued CONTENTS: Return to material from previous lecture At-home programming exercises Please Do Ask Questions It's perfectly normal not to understand everything Most of
More informationName SECTION: 12:45 2:20. True or False (12 Points)
Name SECION: 12:45 2:20 rue or False (12 Points) 1. (12 pts) Circle for true and F for false: F a) Local identifiers have name precedence over global identifiers of the same name. F b) Local variables
More informationChapter 5. Repetition. Contents. Introduction. Three Types of Program Control. Two Types of Repetition. Three Syntax Structures for Looping in C++
Repetition Contents 1 Repetition 1.1 Introduction 1.2 Three Types of Program Control Chapter 5 Introduction 1.3 Two Types of Repetition 1.4 Three Structures for Looping in C++ 1.5 The while Control Structure
More informationMidterm 2. 7] Explain in your own words the concept of a handle class and how it s implemented in C++: What s wrong with this answer?
Midterm 2 7] Explain in your own words the concept of a handle class and how it s implemented in C++: What s wrong with this answer? A handle class is a pointer vith no visible type. What s wrong with
More informationCS-281, Spring 2011 Data Lab: Manipulating Bits Assigned: Jan. 17, Due: Mon., Jan. 31, 11:59PM
CS-281, Spring 2011 Data Lab: Manipulating Bits Assigned: Jan. 17, Due: Mon., Jan. 31, 11:59PM 1 Introduction The purpose of this assignment is to become more familiar with bit-level representations of
More informationIECD Institute for Entrepreneurship and Career Development Bharathidasan University, Tiruchirappalli 23.
Subject code - CCP01 Chapt Chapter 1 INTRODUCTION TO C 1. A group of software developed for certain purpose are referred as ---- a. Program b. Variable c. Software d. Data 2. Software is classified into
More informationCS1132 Fall 2009 Assignment 1. 1 The Monty Hall Dillemma. 1.1 Programming the game
CS1132 Fall 2009 Assignment 1 Adhere to the Code of Academic Integrity. You may discuss background issues and general solution strategies with others and seek help from course staff, but the homework you
More informationMCS-284, Fall 2015 Data Lab: Manipulating Bits Assigned: Sept. 22, Due: Tues., Sept. 29, 11:59PM
MCS-284, Fall 2015 Data Lab: Manipulating Bits Assigned: Sept. 22, Due: Tues., Sept. 29, 11:59PM 1 Introduction The purpose of this assignment is to become more familiar with bit-level representations
More informationHomework Assignment #3
CS 540-2: Introduction to Artificial Intelligence Homework Assignment #3 Assigned: Monday, February 20 Due: Saturday, March 4 Hand-In Instructions This assignment includes written problems and programming
More informationCS 61C: Great Ideas in Computer Architecture. Lecture 3: Pointers. Krste Asanović & Randy Katz
CS 61C: Great Ideas in Computer Architecture Lecture 3: Pointers Krste Asanović & Randy Katz http://inst.eecs.berkeley.edu/~cs61c Agenda Pointers in C Arrays in C This is not on the test Pointer arithmetic
More informationCS 61C: Great Ideas in Computer Architecture. Lecture 3: Pointers. Bernhard Boser & Randy Katz
CS 61C: Great Ideas in Computer Architecture Lecture 3: Pointers Bernhard Boser & Randy Katz http://inst.eecs.berkeley.edu/~cs61c Agenda Pointers in C Arrays in C This is not on the test Pointer arithmetic
More informationControl Structures. Lecture 4 COP 3014 Fall September 18, 2017
Control Structures Lecture 4 COP 3014 Fall 2017 September 18, 2017 Control Flow Control flow refers to the specification of the order in which the individual statements, instructions or function calls
More informationCSCI 136 Data Structures & Advanced Programming. Fall 2018 Instructors Bill Lenhart & Bill Jannen
CSCI 136 Data Structures & Advanced Programming Fall 2018 Instructors Bill Lenhart & Bill Jannen Administrative Details Lab 1 handout is online Prelab (should be completed before lab): Lab 1 design doc
More informationEE 422C HW 6 Multithreaded Programming
EE 422C HW 6 Multithreaded Programming 100 Points Due: Monday 4/16/18 at 11:59pm Problem A certain theater plays one show each night. The theater has multiple box office outlets to sell tickets, and the
More informationAustralian Informatics Olympiad Thursday 23 August, Information Booklet
Australian Informatics Olympiad Thursday 23 August, 2018 Information Booklet Information for Teachers and Students Contest Rules Why Did I Score Zero? Please read this booklet before the day of the contest
More informationAssignment 5: MyString COP3330 Fall 2017
Assignment 5: MyString COP3330 Fall 2017 Due: Wednesday, November 15, 2017 at 11:59 PM Objective This assignment will provide experience in managing dynamic memory allocation inside a class as well as
More information15-122: Principles of Imperative Computation, Fall 2015
15-122 Programming 5 Page 1 of 10 15-122: Principles of Imperative Computation, Fall 2015 Homework 5 Programming: Clac Due: Thursday, October 15, 2015 by 22:00 In this assignment, you will implement a
More informationCS143 Handout 05 Summer 2011 June 22, 2011 Programming Project 1: Lexical Analysis
CS143 Handout 05 Summer 2011 June 22, 2011 Programming Project 1: Lexical Analysis Handout written by Julie Zelenski with edits by Keith Schwarz. The Goal In the first programming project, you will get
More informationProgram Organization and Comments
C / C++ PROGRAMMING Program Organization and Comments Copyright 2013 Dan McElroy Programming Organization The layout of a program should be fairly straight forward and simple. Although it may just look
More informationdo { statements } while (condition);
Topic 4 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 informationWeek 2: Console I/O and Operators Arithmetic Operators. Integer Division. Arithmetic Operators. Gaddis: Chapter 3 (2.14,3.1-6,3.9-10,5.
Week 2: Console I/O and Operators Gaddis: Chapter 3 (2.14,3.1-6,3.9-10,5.1) CS 1428 Fall 2014 Jill Seaman 1 2.14 Arithmetic Operators An operator is a symbol that tells the computer to perform specific
More informationCPE 112 Spring 2015 Exam III (100 pts) April 8, True or False (12 Points)
Name rue or False (12 Points) 1. (12 pts) Circle for true and F for false: F a) Local identifiers have name precedence over global identifiers of the same name. F b) Local variables retain their value
More informationRemaining Enhanced Labs
Here are some announcements regarding the end of the semester, and the specifications for the last Enhanced Labs. Don t forget that you need to take the Common Final Examination on Saturday, May 5, from
More informationCSCE 206: Structured Programming in C++
CSCE 206: Structured Programming in C++ 2017 Spring Exam 2 Monday, March 20, 2017 Total - 100 Points B Instructions: Total of 13 pages, including this cover and the last page. Before starting the exam,
More informationProblem Set 6. Part A:
Introduction to Algorithms: 6.006 Massachusetts Institute of Technology April 12, 2011 Professors Erik Demaine, Piotr Indyk, and Manolis Kellis Problem Set 6 Problem Set 6 This problem set is divided into
More informationEECS 213, Spring 2013 Data Lab: Manipulating Bits
EECS 213, Spring 2013 Data Lab: Manipulating Bits 1 Introduction The purpose of this assignment is to become more familiar with bit-level representations of integers and floating point numbers. You ll
More informationCIT 590 Homework 5 HTML Resumes
CIT 590 Homework 5 HTML Resumes Purposes of this assignment Reading from and writing to files Scraping information from a text file Basic HTML usage General problem specification A website is made up of
More informationIntroduction to C++ Introduction to C++ 1
1 What Is C++? (Mostly) an extension of C to include: Classes Templates Inheritance and Multiple Inheritance Function and Operator Overloading New (and better) Standard Library References and Reference
More informationEE 355 Lab 3 - Algorithms & Control Structures
1 Introduction In this lab you will gain experience writing C/C++ programs that utilize loops and conditional structures. This assignment should be performed INDIVIDUALLY. This is a peer evaluated lab
More informationCS Fall Homework 11 p. 1. CS Homework 11
CS 111 - Fall 2018 - Homework 11 p. 1 Deadline 11:59 pm on MONDAY, December 3, 2018 Purpose To practice with loops, arrays, and more! How to submit Submit your THREE.cpp FILES: CS 111 - Homework 11 hw11.cpp
More informationCS 051 Homework Laboratory #2
CS 051 Homework Laboratory #2 Dirty Laundry Objective: To gain experience using conditionals. The Scenario. One thing many students have to figure out for the first time when they come to college is how
More informationLAB: INTRODUCTION TO FUNCTIONS IN C++
LAB: INTRODUCTION TO FUNCTIONS IN C++ MODULE 2 JEFFREY A. STONE and TRICIA K. CLARK COPYRIGHT 2014 VERSION 4.0 PALMS MODULE 2 LAB: FUNCTIONS IN C++ 2 Introduction This lab will provide students with an
More informationFunction. Mathematical function and C+ + function. Input: arguments. Output: return value
Lecture 9 Function Mathematical function and C+ + function Input: arguments Output: return value Sqrt() Square root function finds the square root for you It is defined in the cmath library, #include
More informationObjectives. 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[Page 177 (continued)] a. if ( age >= 65 ); cout << "Age is greater than or equal to 65" << endl; else cout << "Age is less than 65 << endl";
Page 1 of 10 [Page 177 (continued)] Exercises 4.11 Identify and correct the error(s) in each of the following: a. if ( age >= 65 ); cout
More informationSlide Set 3. for ENCM 339 Fall 2017 Section 01. Steve Norman, PhD, PEng
Slide Set 3 for ENCM 339 Fall 2017 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary September 2017 ENCM 339 Fall 2017 Section 01
More informationAPCS-AB: Java. Recursion in Java December 12, week14 1
APCS-AB: Java Recursion in Java December 12, 2005 week14 1 Check point Double Linked List - extra project grade Must turn in today MBCS - Chapter 1 Installation Exercises Analysis Questions week14 2 Scheme
More informationCOMP-202 Unit 4: Programming With Iterations. CONTENTS: The while and for statements
COMP-202 Unit 4: Programming With Iterations CONTENTS: The while and for statements Introduction (1) Suppose we want to write a program to be used in cash registers in stores to compute the amount of money
More informationLecture 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 informationGB Programming Challenges
GB21802 - Programming Challenges Week 1 - Ad-hoc problems Claus Aranha caranha@cs.tsukuba.ac.jp College of Information Science April 18, 2014 Some Notes Before the Class Don t forget to send me your username
More informationMore Flow Control Functions in C++ CS 16: Solving Problems with Computers I Lecture #4
More Flow Control Functions in C++ CS 16: Solving Problems with Computers I Lecture #4 Ziad Matni Dept. of Computer Science, UCSB Administrative CHANGED T.A. OFFICE/OPEN LAB HOURS! Thursday, 10 AM 12 PM
More informationIntroduction to Programming in C Department of Computer Science and Engineering. Lecture No. #43. Multidimensional Arrays
Introduction to Programming in C Department of Computer Science and Engineering Lecture No. #43 Multidimensional Arrays In this video will look at multi-dimensional arrays. (Refer Slide Time: 00:03) In
More information