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

Similar documents
CS Spring 05 - MidTerm

C++ Final Exam 2017/2018

1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol.

switch case Logic Syntax Basics Functionality Rules Nested switch switch case Comp Sci 1570 Introduction to C++

CPE 112 Spring 2015 Exam III (100 pts) April 8, True or False (12 Points)

CSI33 Data Structures

Name SECTION: 12:45 2:20. True or False (12 Points)


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

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

Test Results Schedule Miscellanea Control Structs. Add l Oper s Break Hands on Q & A Conclusion References Files

Chapter 5: Control Structures II (Repetition) Objectives (cont d.) Objectives. while Looping (Repetition) Structure. Why Is Repetition Needed?

Chapter 7. Additional Control Structures

1) What of the following sets of values for A, B, C, and D would cause the string "one" to be printed?

Increment and the While. Class 15

True or False (14 Points)

*Starting Out with C++: From Control Structures through Objects, 7/E* by *Tony Gaddis* COMPUTER PROGRAMMING LECTURE 05 LOOPS IMRAN IHSAN

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

INTRODUCTION TO COMPUTER SCIENCE - LAB

Input And Output of C++

Control Structures of C++ Programming (2)

5.1. Chapter 5: The Increment and Decrement Operators. The Increment and Decrement Operators. Looping. ++ is the increment operator.

Name Section: M/W or T/TH. True or False (14 Points)

Chapter-8 DATA TYPES. Introduction. Variable:

1. In C++, reserved words are the same as predefined identifiers. a. True

Tokens, Expressions and Control Structures

Name Section: M/W T/TH Number Definition Matching (8 Points)

Programming. C++ Basics

ECE 122. Engineering Problem Solving with Java

True or False (15 Points)

Chapter 5: Loops and Files

REPETITION CONTROL STRUCTURE LOGO

Chapter 5: Prefix vs. Postfix 8/19/2018. The Increment and Decrement Operators. Increment and Decrement Operators in Program 5-1

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

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

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

CSc Introduc/on to Compu/ng. Lecture 8 Edgardo Molina Fall 2011 City College of New York

P.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above

Test Bank for Problem Solving with C++: The Object of Programming, 8/e Chapter 2 C++ Basics

Review Summer CSC1322 Adv Programming in C++ Professor: Zhang

Introduction to Programming

6. User Defined Functions I

Definition: Data Type A data type is a collection of values and the definition of one or more operations on those values.

C++ Programming: From Problem Analysis to Program Design, Fourth Edition. Chapter 5: Control Structures II (Repetition)

Decision Making in C

CS 1044 Homework Assignment 4 Summer I 2001

Looping. Arizona State University 1

Name Section: M/W T/TH Number Definition Matching (6 Points)

CS313D: ADVANCED PROGRAMMING LANGUAGE

Agenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures

Simple vs Structured Data

CS150 Intro to CS I. Fall Fall 2017 CS150 - Intro to CS I 1

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

Name :. Roll No. :... Invigilator s Signature : INTRODUCTION TO PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70

CSCI 1061U Programming Workshop 2. C++ Basics

LAB 4.1 Relational Operators and the if Statement

COMP322 - Introduction to C++ Lecture 02 - Basics of C++

CPE 112 Spring 2015 Exam II (100 pts) March 4, Definition Matching (8 Points)

CHAPTER 2.2 CONTROL STRUCTURES (ITERATION) Dr. Shady Yehia Elmashad

Chapter 8 - Notes User-Defined Simple Data Types, Namespaces, and the string Type

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

CS201- Introduction to Programming Current Quizzes

Introduction to Programming Using Java (98-388)

Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 5-1

A3-R3: PROGRAMMING AND PROBLEM SOLVING THROUGH 'C' LANGUAGE

5.1. Chapter 5: The Increment and Decrement Operators. The Increment and Decrement Operators. The Increment and Decrement Operators

Chapter 3. More Flow of Control. Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Computer Programming

Data Types. 9. Types. a collection of values and the definition of one or more operations that can be performed on those values

3/12/2018. Structures. Programming in C++ Sequential Branching Repeating. Loops (Repetition)

C-LANGUAGE CURRICULAM

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

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

CSC 126 FINAL EXAMINATION FINAL Spring 2012 B. Name (last, First) Instructor. Total Possible. Received

Definition Matching (10 Points)

CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING Chapter 4: Repetition Control Structure

Computer Programming

Introduction to C++ Introduction. Structure of a C++ Program. Structure of a C++ Program. C++ widely-used general-purpose programming language

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9

Iteration: Intro. Two types of loops: 1. Pretest Condition precedes body Iterates 0+ times. 2. Posttest Condition follows body Iterates 1+ times

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

Introduction to C++ with content from

Short Notes of CS201

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

Variables. Data Types.

Review for Test 1 (Chapter 1-5)

CS201 - Introduction to Programming Glossary By

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14

Main Program. C Programming Notes. #include <stdio.h> main() { printf( Hello ); } Comments: /* comment */ //comment. Dr. Karne Towson University

M1-R4: Programing and Problem Solving using C (JAN 2019)

o Counter and sentinel controlled loops o Formatting output o Type casting o Top-down, stepwise refinement

EEE145 Computer Programming

C++ Programming Lecture 7 Control Structure I (Repetition) Part I

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

Lecture 7 Tao Wang 1

CS2141 Software Development using C/C++ C++ Basics

CSC 1300 Exam 4 Comprehensive-ish and Structs

Review of the C Programming Language for Principles of Operating Systems

Exercise: Using Numbers

Control Structures. Repetition (Loop) Structure. Repetition (Loop) Structure. Repetition (Loop) Structure. CS225: Slide Set 8: C++ Loop Structure

Transcription:

The University of Alabama in Huntsville Electrical and Computer Engineering CPE 112 02 Example of Objective Test Questions for Test 4 True or False Name: 1. The statement switch (n) case 8 : alpha++; case 3 : beta++; default : gamma++; is equivalent to the following statement. if (n == 8) alpha++; else if (n == 3) beta++; else gamma++; 2. To avoid infinite loops, a Do-While statement s condition must be false at some time during its execution. 3. A For loop is a posttest loop, whereas a While loop is a pretest loop. 4. If a loop containing a break statement is nested within a Switch statement, execution of that break statement causes an exit from the loop but not from the Switch statement. 5. The C++ statement alpha /= beta + 25; is equivalent to the statement alpha = alpha / (beta + 25); 6. Because of representational error, two integers should not be compared for exact equality. 7. In the data type defined by

enum Colors RED, GREEN, BLUE; the enumerators are ordered such that RED > GREEN > BLUE. 8. The declaration enum GradeType A, B, C, D, F ; results in a compile-time error. 9. A struct is a homogeneous structured data type. 10. To select a member of a struct, you specify the member name, then a dot, and then the struct variable name. 11. C++ allows a struct to be a member of another struct. 12. C++ operators that may be applied to struct variables are assignment (=), equality testing (==), and member selection (.). Fill in the Blank 13. In C++, the statement is the special control structure designed for multi-way branches. 14. When used for a count-controlled loop, the C++ statement is the looping structure that collects into one location the initialization, testing, and incrementation of the loop control variable. 15. A loop is the general name given to a loop in which the loop test is positioned after the loop body. 16. Data types in which each value is atomic (indivisible) are known as types. 17. is the conversion of a value from a "lower" type to a "higher" type according to a programming language s precedence of data types. 18. A(n) is a user-defined data type whose domain is an ordered set of literal values expressed as identifiers. 19. A record in which at least one of the components is itself a record is called a(n) record.

20. A record (struct) is said to be a(n) data type because its components can be of different data types. Multiple Choice 21. Which of the following is not a C++ looping control structure? a. While b. For c. Do-While d. Switch 22. What is the output of the following code fragment if the input value is 4? (Be careful here.) int num; int alpha = 10; cin >> num; switch (num) case 3 : alpha++; case 4 : alpha = alpha + 2; case 8 : alpha = alpha + 3; default : alpha = alpha + 4; cout << alpha << endl; a. 10 b. 14 c. 12 d. 19 e. 15 23. To produce the output 2 4 6 8 10, what is the loop condition for the following loop? n = 0; do n = n + 2; cout << n << ; while (??? ); a. n <= 10 b. n < 10 c. n < 8 d. n >= 2 e. n > 8

24. Which For loop is equivalent to the following While loop? (All variables are of type int.) count = -5; while (count <= 15) a. for (count = -5; count <= 15; count++) b. for (count = -5; count <= 15; count++) c. for (count = -5; count <= 15; count++) d. for (count = 1; count <= 21; count++) 25. Given the declarations enum MovieRatings G, PG, PG13, R, X; MovieRatings thisone; and assuming that thisone currently contains a value less than X, which of the following statements can be used to "increment" thisone? a. thisone = thisone + 1; b. thisone++; c. MovieRatings(thisOne++); d. thisone = MovieRatings(thisOne + 1); e. thisone = MovieRatings(thisOne) + 1; 26. You have created some useful type declarations and constant declarations and have stored them into a file named mystuff.h. Which of the following would you use to insert the contents of this file into a program? a. #include <mystuff.h> b. #include "mystuff.h" c. #include mystuff.h d. #insert mystuff.h 27. A struct is an example of: a. a simple data type b. a homogeneous structured type

c. a heterogeneous structured type d. an enumeration type 28. In C++, which of the following is not allowed as an aggregate operation on structs? a. assignment b. I/O c. parameter passage by value d. parameter passage by reference e. return as a function s return value 29. Given the declarations typedef char String19[20]; struct BrandInfo String19 company; String19 model; ; struct DiskType BrandInfo brand; float capacity; ; DiskType mydisk; which of the following assignment statements is valid? a. mydisk.capacity = 1.44; b. mydisk.brandinfo = "Memorex"; c. strcpy(mydisk.brandinfo, "Memorex"); d. a and c above e. none of the above