Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

CPE 211 Final exam with complete solutions

Rating
-
Sold
-
Pages
18
Grade
A+
Uploaded on
01-08-2022
Written in
2022/2023

Which of the following is a way to put a comment into a C++ program? / comment / Which of the following are ways to structure statements in most programming languages(more than one answer is possible here. you need to select them all) Sequentially Loop Subprogram Selection 01:02 01:33 The implementation phase of computer programming involves which one of the following: converting the algorithm steps into a programming language The job of a compiler is to do what? translate a high level programming language into machine language Which of the following is a problem solving technique mentioned in the slides for chapter 1? Divide and Conquer An expression is an arrangement of ____________, _________________ and ______________ that can be evaluated to compute a value of a given type. Operations Literals Identifiers From the notes and text, "The set of rules determining the meaning of the instructions written" is the definition for _______________________ Semantics In C++ using strict ANSII standard C++ (and as mentioned for this course), identifiers can start with what character(s) (more than one answer is possible)? Underscores Letters In an assignment statement more than 1 variable can be present on the left hand side of the statement - i.e. x + y =30; is a valid assignment statement False Every C++ program must have a function named start True The insertion operator is used to insert information into the output file stream in C++? True In C++ capitalization of identifiers does not matter because identifiers NAME and name are considered to be the same identifier by the compiler? False In C++, which of the following operators are valid integer math operators? / * + % Which of the following are output file stream manipulators? setprecission left showpoint Given the C++ code segment below, string str1, str2; str1 = "The_third_Quiz_in_CPE211"; str2 = r(4,8);cout str2; What is the string value output by the output statement? third_Qu Which of the following is a valid Named Constant Declaration in C++? const string NAME = "Elm"; in C++ the following statement will increment num by 1? num++; True The following C++ statement is an example of type casting the integer variable num to a floating point value: int num; float var; var = (num)float; False in C++ the result of the integer division of 6/4 is 1.5? False Typically, information is lost when a floating point value is coerced to an integer value. True In C++ the following assignment statement is valid? num1 = num2 = num3 = num4 = 0; True in C++, void functions return a single function value? False Which of the following statements will associate the file with the output file stream variable outFile? (assume all variables and file streams have been declared correctly and that all header files are present) outF(""); Which of the following functions is used to associate a file on the hard drive with a declared file stream variable open For the code segment below, what is the value output if the user types in 1 A 2 (select the best possible answer) int num1, num2, num3;] cout "Enter in 3 integersn"; cin num1 num2 num3; cout num3; do not know - file stream went into fail state The statement (ch); obtains the next character, regardless of what it is, from the standard input stream cin? (ch is declared as a character variable) True In C++ when using the open function, the argument for the open function must be a string variable False The ignore statement e(20); will always ignore 20 characters on the input stream cin? True The two character sequence n is used to represent the new line character in C++ and it can be stroed in a character variable? True The statement getline(cin, str1); reads an entire line ending in a ? into the string variable str1? False Before the code shown below is executed, the input stream (cin) contains the following characters (n represents the new line character) : 500BnHello 66n44n33and the reading marker is on the 5 Using the space provided, write what is output to the terminal by the following segment of code. int m = 10; int x = 20; string text = "Null"; char ch = 'A';getline(cin,text,'n'); e(5,'n'); cin m ch; cout m "-" ch "-" x "-" text endl; xt endl; B In C++ any non-zero integer value is coerced to a boolean value of true True When used with a file stream, the clear() function will reset all the status bits for the file stream so that it can be used again. True In an if-then-else-if logic statement, all logical expressions are always evaluated False If x=10 and y=10, What is the boolean value for the relational expression: x != y False The result of a logical expression using the OR (||) logical operator is true if at least one of the operands is a boolean true value? true What is the output for the following code segment? a = 40;i f (a20) cout "20"; else if (a 30) cout "30"; else if (a 40) cout "40"; 20 What are the three versions of the if statement discussed in the lecture notes and example programs? If-Then-Else If-Then If-Then-Else-If Which of the following logical expressions evaluate as true? false||true true||false true||true Which of the following logical expressions evaluate as true? true&&true Which of the following are Logical operators? || = == != && !(Maybe? we can't see the correct answer) The end of file status bit is changed from false to true when an attempt is made to read beyond the end of an input file? True For sentinel controlled loops, the best sentinel is a value that IS expected as normal input for the program? false The body of a while loop will execute zero or more times depending on the status of the while expression that is tested? True In a loop, event counters are incremented every time the loop body is executed. False In C++ it is a syntax error if a loop is declared inside the body of another loop? - (in other words it is illegal in c++ to nest loops) False What is the output of the following loop? int a = 0; while (a = 5) { cout a;a++; } cout endl "donen"; done What is the output of the following loop segment? int a = 0; int sum = 0 while (a = 5){ sum = sum + a; a++; } cout sum endl; 0 Which of the following are functions that return the boolean status of a file stream status bit? fail() good() eof() Which of the following are types of Event Controlled Loops? EndOfFile controlled Sentinel Controlled Flag Controlled Write a count controlled loop that will output the numbers 1, 2, 3, 4 and 5 (one per line) #include iostream using namespace std; int main(){ int a = 0; while (a = 5){ a++; coutaendl; } return 0; } Write a sentinel controlled loop that prompts the user to enter a number, reads the number and continues to loop prompting for and reading numbers until the number entered is greater than 0. Do not forget the priming read. This loop is just prompting for and reading in a number - it is not doing any processing on that number. #include iostream using namespace std; int main(){ int a; cout"enter a number:"; cina; while (a = 0){cout"enter a number:"; cina; } return 0; } A continue statement will cause the immediate exit of the loop in which it appears? False In a switch statement, a variable can be used as a case label? False The default label is required in a switch statement? False In a switch statement there can be 0 or more statements associated with a Switch Label? true In a switch statement, if the switch expression matches a case label, control branches to the statements associated with the default label? False A break statement causes the immediate exit from the loop or switch statement in which it appears? True Which of the following data types can be used as a switch expression? Integer Character Boolean A continue; statement can be used in which of the following C++ control structures? ... What is the output for the following switch statement: int num = 0; while (num 5){ switch(num) { case 1:cout "1"; case 2:cout "2"; break; case 3:cout "3"; default:cout "4"; } num++; } What is the output for the following do-while loop? int num = 0; do{ num++; cout num "-"; }while(num 5); 1-2-3-4-5- When local variables are declared, they start with their values undefined? True Reference parameters receive the memory address of the corresponding argument? True Value returning functions can use the statement return; false void function calls must occur as part of an expression? False A value parameter is automatically initialized to the value of the corresponding argument. True Local variables declared inside a block statement can be accessed out of that block statement? False What is the definition for a function definition? The code that extends from the function heading to the end of the block that is the body of the function What is the definition for a function call? The statement that transfers control to a function Which of the following can be used as arguments in a function call when the argument is paired up with a reference parameter? Variables

Show more Read less
Institution
Course

Content preview

CPE 211 Final exam
Which of the following is a way to put a comment into a C++ program? - Answer /*
comment */

Which of the following are ways to structure statements in most programming
languages(more than one answer is possible here. you need to select them all) -
Answer Sequentially
Loop
Subprogram
Selection

The implementation phase of computer programming involves which one of the
following: - Answer converting the algorithm steps into a programming language

The job of a compiler is to do what? - Answer translate a high level programming
language into machine language

Which of the following is a problem solving technique mentioned in the slides for
chapter 1? - Answer Divide and Conquer

An expression is an arrangement of ____________, _________________ and
______________ that can be evaluated to compute a value of a given type. - Answer
Operations
Literals
Identifiers

From the notes and text, "The set of rules determining the meaning of the instructions
written" is the definition for _______________________ - Answer Semantics

In C++ using strict ANSII standard C++ (and as mentioned for this course), identifiers
can start with what character(s) (more than one answer is possible)? - Answer
Underscores
Letters

In an assignment statement more than 1 variable can be present on the left hand side of
the statement - i.e. x + y =30; is a valid assignment statement - Answer False

Every C++ program must have a function named start - Answer True

The insertion operator << is used to insert information into the output file stream in C+
+? - Answer True

In C++ capitalization of identifiers does not matter because identifiers NAME and name
are considered to be the same identifier by the compiler? - Answer False

,In C++, which of the following operators are valid integer math operators? - Answer /
*
+
%

Which of the following are output file stream manipulators? - Answer setprecission
left
showpoint

Given the C++ code segment below,

string str1, str2;
str1 = "The_third_Quiz_in_CPE211";
str2 = str1.substr(4,8);cout << str2;

What is the string value output by the output statement? - Answer third_Qu

Which of the following is a valid Named Constant Declaration in C++? - Answer const
string NAME = "Elm";

in C++ the following statement will increment num by 1?

num++; - Answer True

The following C++ statement is an example of type casting the integer variable num to a
floating point value:

int num;
float var;
var = (num)float; - Answer False

in C++ the result of the integer division of 6/4 is 1.5? - Answer False

Typically, information is lost when a floating point value is coerced to an integer value. -
Answer True

In C++ the following assignment statement is valid?

num1 = num2 = num3 = num4 = 0; - Answer True

in C++, void functions return a single function value? - Answer False

Which of the following statements will associate the file out.txt with the output file stream
variable outFile? (assume all variables and file streams have been declared correctly
and that all header files are present) - Answer outFile.open("out.txt");

, Which of the following functions is used to associate a file on the hard drive with a
declared file stream variable - Answer open

For the code segment below, what is the value output if the user types in 1 A 2 (select
the best possible answer)

int num1, num2, num3;]
cout << "Enter in 3 integers\n";
cin >> num1 >> num2 >> num3;
cout << num3; - Answer do not know - file stream went into fail state

The statement cin.get(ch); obtains the next character, regardless of what it is, from the
standard input stream cin? (ch is declared as a character variable) - Answer True

In C++ when using the open function, the argument for the open function must be a
string variable - Answer False

The ignore statement cin.ignore(20); will always ignore 20 characters on the input
stream cin? - Answer True

The two character sequence \n is used to represent the new line character in C++ and it
can be stroed in a character variable? - Answer True

The statement getline(cin, str1); reads an entire line ending in a ? into the string variable
str1? - Answer False

Before the code shown below is executed, the input stream (cin) contains the following
characters
(\n represents the new line character) :

500B\nHello 66\n44\n33and the reading marker is on the 5

Using the space provided, write what is output to the terminal by the following segment
of code.
int m = 10;
int x = 20;
string text = "Null";
char ch = 'A';getline(cin,text,'\n');
cin.ignore(5,'\n');
cin >> m >> ch;
cout << m << "-" << ch << "-" << x << "-" << text << endl;
xt << endl; - Answer 66-4-20-500B

In C++ any non-zero integer value is coerced to a boolean value of true - Answer True

Written for

Course

Document information

Uploaded on
August 1, 2022
Number of pages
18
Written in
2022/2023
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$8.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
satamu Arizona Western College
Follow You need to be logged in order to follow users or courses
Sold
260
Member since
3 year
Number of followers
216
Documents
4593
Last sold
2 months ago
Nursing school is hard....I can help!!!

STUDY GUIDE,CASE STUDY,ASSIGNMENTS,TEST BANKS &amp; EXAMS ALL VERIFIED BY EXPERTS TO GUARANTEE AN EXCELLENT SCORE!!! HI! I will be providing you all with quality study materials, to be specific nursing documents. my aim is to help each and every student. I sell my documents at a fair price to make it easier for students to purchase and attain best grades. GOOD LUCK!!

4.1

58 reviews

5
32
4
10
3
11
2
1
1
4

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions