CSC 1300 Exam 4 Comprehensive-ish and Structs

Similar documents
Homework #3 CS2255 Fall 2012

Exam 3 Chapters 7 & 9

CS2255 HOMEWORK #1 Fall 2012

FORM 2 (Please put your name and form # on the scantron!!!!)

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):

CS 161 Exam II Winter 2018 FORM 1

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

Add Subtract Multiply Divide

Introduction to Computer Science Midterm 3 Fall, Points

Pointers, Dynamic Data, and Reference Types

Operators. Java operators are classified into three categories:

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

Pointers II. Class 31

Reference operator (&)

CSCE 206: Structured Programming in C++

CSCE 206: Structured Programming in C++

FORM 2 (Please put your name and form # on the scantron!!!!) CS 161 Exam II:

Pointers. Addresses in Memory. Exam 1 on July 18, :00-11:40am

CSI33 Data Structures

[0569] p 0318 garbage

Tokens, Expressions and Control Structures

EMBEDDED SYSTEMS PROGRAMMING Language Basics

CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011. MIDTERM EXAMINATION Spring 2010

Lecture 14. No in-class files today. Homework 7 (due on Wednesday) and Project 3 (due in 10 days) posted. Questions?

C PROGRAMMING LANGUAGE. POINTERS, ARRAYS, OPERATORS AND LOOP. CAAM 519, CHAPTER5

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

Introduction to Programming using C++

Chapter 2: Basic Elements of C++

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

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

Chapter 3, Selection. Liang, Introduction to Programming with C++, Second Edition, (c) 2010 Pearson Education, Inc. All rights reserved.

Arrays. Lecture 9 COP 3014 Fall October 16, 2017

Abstract Data Type (ADT) & ARRAYS ALGORITHMS & DATA STRUCTURES I COMP 221

1) You want to determine whether time has run out. The following code correctly implements this:

Decision Making in C

CS Introduction to Programming Midterm Exam #2 - Prof. Reed Fall 2015

CSCI-1200 Data Structures Fall 2017 Lecture 5 Pointers, Arrays, & Pointer Arithmetic

FORM 1 (Please put your name and form # on the scantron!!!!) CS 161 Exam I: True (A)/False(B) (2 pts each):

5. Assuming gooddata is a Boolean variable, the following two tests are logically equivalent. if (gooddata == false) if (!

Dynamic Allocation of Memory

CS201- Introduction to Programming Current Quizzes

C++ Basics. Data Processing Course, I. Hrivnacova, IPN Orsay

8. Functions (II) Control Structures: Arguments passed by value and by reference int x=5, y=3, z; z = addition ( x, y );

Creating a C++ Program

Pointers. Reference operator (&) ted = &andy;

Input And Output of C++

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

C++ Programming: From Problem Analysis to Program Design, Third Edition

CS Spring 05 - MidTerm

The C++ Language. Arizona State University 1

Exam 1. CSI 201: Computer Science 1 Fall 2018 Professors: Shaun Ramsey

Chapter 9: Pointers Co C pyr py igh i t gh Pear ea so s n n E ducat ca io i n, n Inc. n c.

CS 31 Review Sheet. Tau Beta Pi - Boelter Basics 2. 2 Working with Decimals 2. 4 Operators 3. 6 Constants 3.

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

Software Design & Programming I

7/8/10 KEY CONCEPTS. Problem COMP 10 EXPLORING COMPUTER SCIENCE. Algorithm. Lecture 2 Variables, Types, and Programs. Program PROBLEM SOLVING

Review Chapter 6 in Bravaco. Short Answers 1. This type of method does not return a value. a. null b. void c. empty d. anonymous

Chapter 9: Pointers. Copyright 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved.

Chapter 9: Getting the Address of a Variable. Something Like Pointers: Arrays. Pointer Variables 8/23/2014. Getting the Address of a Variable

UNIT- 3 Introduction to C++

CS31 Discussion. Jie(Jay) Wang Week8 Nov.18

Control Structures. Lecture 4 COP 3014 Fall September 18, 2017

Chapter 1: Object-Oriented Programming Using C++

Programming. C++ Basics

cout << "How many numbers would you like to type? "; cin >> memsize; p = new int[memsize];

Pointers! Arizona State University 1

Basic program The following is a basic program in C++; Basic C++ Source Code Compiler Object Code Linker (with libraries) Executable

(Not Quite) Minijava

CAMBRIDGE SCHOOL, NOIDA ASSIGNMENT 1, TOPIC: C++ PROGRAMMING CLASS VIII, COMPUTER SCIENCE

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

Introduction to Computers and C++ Programming p. 1 Computer Systems p. 2 Hardware p. 2 Software p. 7 High-Level Languages p. 8 Compilers p.

C++ Basic Elements of COMPUTER PROGRAMMING. Special symbols include: Word symbols. Objectives. Programming. Symbols. Symbols.

Chapter 3: Arrays and More C Functionality

Chapter 11: Structured Data

Array Elements as Function Parameters

Flow Control. CSC215 Lecture

Non-numeric types, boolean types, arithmetic. operators. Comp Sci 1570 Introduction to C++ Non-numeric types. const. Reserved words.

Quiz Start Time: 09:34 PM Time Left 82 sec(s)

CS201 Latest Solved MCQs

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

A SHORT COURSE ON C++

Chapter 2. C++ Syntax and Semantics, and the Program Development Process. Dale/Weems 1

C Introduction. Comparison w/ Java, Memory Model, and Pointers

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

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

Dynamic Memory Allocation

CS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor

Pointers and Arrays CS 201. This slide set covers pointers and arrays in C++. You should read Chapter 8 from your Deitel & Deitel book.

Midterm Practice TA: Brian Choi Section Webpage:

The following expression causes a divide by zero error:

Arithmetic Operators. Binary Arithmetic Operators. Arithmetic Operators. A Closer Look at the / Operator. A Closer Look at the % Operator

Structured Data. CIS 15 : Spring 2007

Memory and Pointers written by Cathy Saxton

Variables, Memory and Pointers

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

CSC 211 Intermediate Programming. Pointers

The University of Alabama in Huntsville Electrical and Computer Engineering CPE Example of Objective Test Questions for Test 4

Chapter 11: Structured Data

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

Object oriented programming C++

Transcription:

CSC 1300 Exam 4 Comprehensive-ish and Structs December 8, 2017 Name: Read through the entire test first BEFORE starting Multiple Choice and T/F sections should be completed on the scantron Test has two sections worth a total of 100 points o True / False / Multiple Choice 30 questions, 75 points o Code 1 question, 25 points Section 1 (75 points) 1. This is required after the closing brace of the structure definition a. Curly bracket b. Square bracket c. Period d. Semicolon 2. Look at the following statement booklist[2].publisher[3] = t ; This statement a. Is illegal in C++ b. Will change the publisher s name of the second book in booklist to t c. Will store the character t in the fourth element of the publisher member of booklist[2] d. Will ultimately result in a runtime error 3. You may use a pointer to a structure as a a. Function parameter b. Structure member c. Function return type d. All of these 4. Data types that are created by the programmer are known as a. Variables b. Abstract data types (ADT) c. Functions d. Parameters 5. Before a structure can be used, it must be a. declared b. dereferenced c. initialized d. constructed Pg. 1

6. The, also known as the address operator, returns the memory address of a variable a. asterisk b. ampersand c. percent sign d. exclamation point 7. When you work with a dereferenced pointer, you are actually working with a. a variable whose memory has been allocated b. a copy of the value pointed to by the pointer variable c. the actual value of the variable whose address is stored in the pointer variable d. all of the above 8. A function return a structure a. will always b. may c. may not d. cannot possibly 9. To dereference a structure pointer, the appropriate operator is a. the ampersand, & b. an asterisk, * c. the structure pointer operator, -> d. the dereference operator, <- 10. If Circle is a structure, the statement Circle* pcirc = nullptr; a. is illegal in C++ b. initializes a null pointer with the value of the Circle pointer c. declares an empty structure variable called *pcirc d. declares a structure pointer called pcirc initialized with a null pointer 11. With an enumerated data type, the enumerators are stored in memory as a. strings b. integers c. characters d. doubles 12. A struct can contain members with varying data types 13. If a function is legally prototyped to return an integer value, it can return a structure member that is an integer data type 14. Dynamic memory allocation occurs when a. a new variable is created by the compiler b. a pointer fails to dereference the right variable c. a new variable is created at runtime d. a pointer is assigned an incorrect address Pg. 2

15. Every byte in the computer s memory is assigned a unique a. pointer b. address c. name d. dynamic allocator 16. C++ does not perform array bounds checking, making it possible for you to assign a pointer the address of an element out of the boundaries of an array 17. The ampersand is used to dereference a pointer variable in C++ 18. Relational operators allow you to numbers a. add b. multiply c. compare d. average 19. Assuming the user enters a 90 to the keyboard, what will the following code output? cout << Enter a test score ; cin >> testscore; if (testscore < 60); cout << You failed the test << endl; if (testscore > 60) cout << You passed the test << endl; else cout << You need to study for the next test! << endl; a. You failed the test b. You passed the test c. You failed the test You need to study for the next test! d. You failed the test You passed the test 20. This operator represents the logical AND a. ++ b. c. && d.! 21. Input values from the user should always be checked for a. Appropriate range b. Reasonableness c. Division by zero (if division taking place) d. All of these Pg. 3

22. The default section is required in a switch statement 23. As a rule of style, when writing an if statement you should indent the conditionally executed statements 24. To access an array element, use the array name and the element s a. Data type b. subscript c. numbers d. constants 25. The name of an array stores the of the first array element a. memory address b. data type c. element number d. value 26. Which of the following is a valid C++ array definition? a. int scores[0]; b. float $payments[10]; c. int readings [4.5]; d. int scores [10]; e. B and D are both valid 27. An array with no elements is a. legal in C++ b. illegal in C++ c. automatically furnished with one element with a value of zero d. automatically furnished with one element, the null terminator 28. A for loop contains three expressions, initialization, test and a. update b. reversal c. null d. validation 29. One reason for using functions is to break programs into manageable units, or modules 30. All of the other True/False questions were True Pg. 4

Section 2 Code (25 points) You have been hired by the National Collegiate Athletics Association (NCAA) to help build a database of all of their 300+ member schools. Your job will be to create the initial data type to hold the information the association keeps on each school. This information is : A string containing the name of the institution (e.g. Tennessee Tech University) A string containing the institutions team name (e.g. Golden Eagles) A string containing the city where the institution is located (e.g. Cookeville) A string containing the state where the institution is located (e.g. TN) An integer containing the year the when the institution was founded (e.g. 1917) An integer containing the total wins all time for the institution An integer containing the total losses all time for the institution A Boolean indicating if the school is currently on probation A string indicating the conference the school currently plays in A string indicating which division the school currently plays in Remember, you are only responsible for creating, displaying and deleting a single team. You must create the.h prototype file as well as the.cpp file containing your code. Pg. 5