Programming Review: Test 1

¡Supera tus tareas y exámenes ahora con Quizwiz!

destructors

-have no return type - cannot accept arguments, so they never haver a parameter list - cannot accept arguments, there can only be one in a program.

What will the following statement output? a = 2; b = 5; c = a * ++b; cout << a << " " << b << " " << c;

2 6 12 (more practice on pg. 257)

What will the following line of code display? cout << "toupper('c');

67 (The ASCII code for C)

What is the assignment operator in this assignment statement? unitsSold = 12;

= (the equal sign)

What is the precedence of relational operators?

>, <, >=, <=, ==, !=

a default constructor

A constructor that requires no arguments is called?

the tilde character(~)

A destructor function name always starts with......?

What does the following program display? int main() { double apple; cout << "An apple can be eaten in " << sizeof(apple) << " bytes!\n"; return 0; }

An apple can be eaten in 8 bytes

ClassAct sally; sally.ClassAct(25);

Assume the following Is a constructor: ClassAct: :ClassAct(int x) { item = x; } Define a ClassAct object called sally that passes the value 25 to the constructor

True/False: the following three statements act the same way num = num + 1; num += 1; num++; //this statement uses the increment operator

True

True/False: the simplest character data type is the char data type

True

True/False: In a do-while loop, the loop will run at least once even if the statement is false from the beginning for example: int x = 1; do cout << x << endl; while (x < 0);

True (More practice on Pg. 270)

cout is classified as a _________ object

stream

In order to create a string type variable, C++ provides something called the _________________

string class

In order to use the sin function you must use what header file?

#include <iostream>

What is the precedence of all the logical operators?

&&, ||, !

What does the following program display? int main() { bool boolValue; boolValue = true; cout << boolValue << endl; boolValue = false; cout << boolValue << endl; return 0; }

1 0

What will the following statement output? a = 2; cout << a++ ;

2

What will the following statement output? a = 2; b = 5; c = a * b++ cout << a << " " << b << " " << c;

2 6 10

True/False: ">>" is used as the stream-insertion operator because the item immediately to the right of the item is inserted into the output stream

False

True/False: A switch statement, the Constant expression can be a variable or boolean expression. For example: case ConstantExpression: //Place one or more statements //here switch(temp) { case temp < 0 : cout << "Temp is negative. \n"; break; case temp == 0: cout << "Temp is zero. \n"; break; case temp > 0: cout << "Temp is positive. \n"; break; }

False

True/False: The #include <string> header is not needed before every problem in which includes string type variables

False

True/False: When you run this main function, " About 192000 days ago Columbus stood on this spot. int main(): { long days = 192,000; cout << About << days << " days ago Columbus"; cout << "stood in this spot. \n"; }

False (About needs to be in quotation marks and remove the comma from 192,000 days variable declaration)

True/False: Many algorithms require a program to execute some statements only under certain circumstances. this can be accomplished with a "sequence structure".

False (Decision structure uses if, if else if, else, statements)

constructors

If the programmer doesn't write any _______________ for a class, the compiler automatically creates one

_______________ operators connect two or more relational expressions into one or reverse the logic of an expression.

Logical

when the following main function runs, what will display on the screen? int main() { int number; number = 712; cout << "The value is " << "number" << endl; return 0; }

The value is number

True/ False: cout << "Programming is great fun!"; & cout << "Programming is " << "great fun!"; both produce the same output

True

True/False: In C++, your are allowed to have the user input two variables at the same time, or with one cin statement. For example: cout << "Please enter the length and width of the square "; cin >> length >> width;

True

True/False: When a floating-point value is assigned to an integer variable the fractional part of the number is discarded. When apart of a value is discarded in this manner, the value is said to be TRUNCATED

True

True/False: When a line beings with a # it indicates it is a "preprocessor directive".

True

while and for loops

What are all the different kinds of pre-test loops in c++?

What will be the result of the following code? long amount; amount = 32L; cout << "You have a total of " << amount << " days remaining"

You have a total of 32 days remaining (the L after 32 is a storing the integer literal as a long integer literal

the _____________ data type is used to store individual characters.

char

A _____________ variable never changes in value once initialized

constant (const)

________ is used to display information on the computer's screen

cout

________________can be thought of as a group of one or more programming statements that has a name.

function

iostream is an example of a ___________ file because it is called at the top or the head of the file

header file

The cout statement is able to print outputs to the computer screen because of what preprocessor file?

iostream

the ________________ function determines if the variable consist of a letter.

isalpha()

the ____________ function checks to see if a position is a blank white space character

isspace()

a ____________ is a piece of data that is written directly into a program's code.

literal

The procedures an object performs are called its_______________

member functions

c++ uses ______________ to organize the names of program entities.

namespaces (for example: int reggie = 0; /* in order for reggie to act as a variable, "reggie" must first have access the std namespace)

What will the following while loop display? int count = 1; while (count < 5); { cout << "My favorite day is sunday \n"; count = count + 1; }

nothing (the loop while go on forever but not print anything)

An _____________ is a software entity that combines both data and the procedures that work with it in a single unit

object

Unlike a while or a for loop, at the end of a do-while loop, you use a ______________ at the end of the "(expression);" expression to end the loop;

semi-colon

A ______________ is a special value that marks the end of a list of values

sentinel

The following statements are placed at the beginning of a while loop. cout << "Entente number of points your team has earned; cout << "\n so far this season. Then enter -1 when finished; The "-1" they are referring too in the statement above is the ______________ value of the program

sentinel (the way for the program to exit the loop)

the ______________ operator may be used to determine the size of a data type on any system.

sizeof

_________ is an extra byte that is put at the end of a string and stores the number zero in it

the null character(null terminator)

A __________________ provides a default action, or set of actions, when none of the if expressions are true and is often used to catch errors

trailing else

a ___________ is a named storage location for holding data.

variable

________________ tells the compiler the variable's name and the type of data it will hold

variable definition


Conjuntos de estudio relacionados

ACT English Multiple Choice Questions

View Set

Biotech CHAPTER 6 Types of Assays

View Set

Chapter 7: Emerging and Early Adulthood

View Set

Plasma Membrane & Plant Cell Wall

View Set

FL Real Estate Practice Quizzes 1-10

View Set

Missouri statutes, rules and regulations common to all lines

View Set