C++ midterm

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

The notation of logical NOT operator in a C++ program is a. / b. | c. ! d. none of th above

!

Which one of the following logical operators is unary (needs just one operand) ? a. && b. ! c. ||

!

Which of the following permits function overloading on c++? a) type b) number of arguments c) both of the mentioned d) none of the mentioned

both of the mentioned

Which one of the following expressions is correct comment a. */ Comments */ b. ** Comment ** c. /* Comment */ d. { Comment }

/* Comment */

How many minimum number of functions are need to be presented in c++? a) 0 b) 1 c) 2 d) 3

1

What is the final value of x when the following code is run: int x; for(x=0; x<10; ++x) { } cout << x A. 1 B. 0 C. 9 D. 10

10

How many ways of passing a parameter are there in c++? a) 1 b) 2 c) 3 d) 4

2

In C++, the instruction 14 % 4; return: a. 1 b. 2 c. 3 d. 4

2

In C++, what is the value of i after this: int i=5 / 2; a. 2.5 b. 2 c. 1 d. 3

2

C++ is a descendant of the C language a. True b. False

True

what is the value of i after this int i=1; (i++)++; a. 1 b. 2 c. 3 d. 4

3

Waht is the value of i : int i = size of (int) a. 1 b. 2 c. 3 d. 4

4

What character ends each instruction in a c++ program ? a. : b. ' c. // d. ;

;

Which of the following is used to terminate the function declaration? a) : b) ) c) ; d) none of the mentioned

;

Which of the following is the correct operator to assign a variable a. == b. =+ c. <= d. =

=

cin in C++ program uses the operator a. << b. >> c. < d. >

>>

The expressions (a*b)+c and a*b + c are similar a. True b. False

True

What output is produced by the segment of code shown below for (int i = 1; i < 5; i++) cout << 'A'; A. A B. AAA C. AAAA D. AAAAA

AAAA

What are the advantages of passing arguments by reference? a) Changes to parameter values within the function also affect the original arguments. b) There is no need to copy parameter values (i.e. less memory used) c) There is no need to call constructors for parameters (i.e. faster) d) All of the mentioned

All of the mentioned

Which of the following is NOT correct for the scope of a global variable? a. Whole source file in which it is defined b. From the point of declaration to the end of the file in which it is defined c. Any source file in a program d. From the point of declaration to the end of the file being compiled

Any source file in a program

The following expressions are similar (a > b) == (b > c) and a > b == b > c a. True b. False

True

The function prototype double mySqrt( int x ); A. Declares a function called mySqrt which takes an integer as an argument and returns a double. B. Defines a function called double which calculates square roots. C. Defines a function called mySqrt which takes an argument of type x and returns a double. D. Declares a function called mySqrt which takes a double as an argument and returns an integer.

Declares a function called mySqrt which takes an integer as an argument and returns a double.

What is the purpose of using functions in C++ language? a. Doing specific tasks b. Making the program to run faster c. Reducing the number of lines of code d. None of the above

Doing specific tasks

A function can return more than one value. a. True b. False

False

Function overloading can also be achieved if two or more functions differ only in their return types. a. True b. False

False

In C++, char type may contain up to 2 letters a. True b. False

False

Mathematicians and computers interpret the equal sign (=) in the same way. a. True b. False

False

The following expressions are similar (a > b) && (c || d) and a > b && c || d a. True b. False

False

The following satement is correct double p= 73,422.56; a. True b. False

False

You must specify void in parameters if a function does not have any arguments. a. True b. False

False

n c++, we can not use more than one library in the same program a. True b. False

False

the input operator cin is defined in the <iomanip> library a. True b. False

False

What is the scope of a function? a) Whole source file in which it is defined b) From the point of declaration to the end of the file in which it is defined c) Any source file in a program d) From the point of declaration to the end of the file being compiled

From the point of declaration to the end of the file being compiled

Assigning one or more function body to the same name is called_______________ a. Function Overriding b. Function Overloading c. Both a and b d. None

Function Overloading

If an argument to a function is declared as const, then a. function can modify the argument b. Function can't modify the argument c. const argument to a function is not possible d. None of these

Function can't modify the argument

Identify the correct statement regarding scope of variables a. Global variables are declared in a separate file and accessible from any program. b. Local variables are declared inside a function and accessible within the function only. c. Global variables are declared inside a function and accessible from anywhere in program. d. Local variables are declared in the main body of the program and accessible only from functions.

Local variables are declared inside a function and accessible within the function only.

Which of the following situation most likely does NOT call for a counting loop? A. Adding up all the integers between zero and one hundred. B. Writing out a table of Fahrenheit and Celcius temperature equivalents. C. Prompting the user of a program until the user responds with correct information. D. Making the computer beep ten times.

Making the computer beep ten times

Which of the following is not a variable type a. Real b. long double c. float d. int

Real

What happens when two blocks, one nested inside of the other, both declare variables with the same identifier? (Assume that the outer block declares its variable before the opening left-brace of the inner block.) A. A syntax error occurs. B. The "outer" variable is hidden while the "inner" variable is in scope. C. The "outer" variable is irretrievably lost when the "inner" variable is declared. D. The "inner" declaration is ignored and the "outer" variable has scope even inside the inner block.

The "outer" variable is hidden while the "inner" variable is in scope.

What will happen while using pass by reference a) The values of those variables are passed to the function so that it can manipulate them b) The location of variable in memory is passed to the function so that it can use the same memory area for its processing c) The function declaration should contain ampersand (& in its type declaration) d) All of the mentioned

The location of variable in memory is passed to the function so that it can use the same memory area for its processing.

The "return 0;" statement in main function indicates a. The program did nothing; completed 0 tasks b. The program worked as expected without any errors during its execution c. Not to end the program yet. d. None of above

The program worked as expected without any errors during its execution

What is wrong with the following switch statement? switch(x) { case 1: cout << x; case 2: cout << 2 / x; break; default: cout << "error"; break; } A. The value of x could be something other than 1 or 2. B. There is no break statement for case 1. C. There is no semicolon after the closing bracket. D. All of the above

There is no break statement for case 1.

A function can have more than one parameter. Values of the parameters are passed to the function when it is called. a. True b. False

True

A local variable declared in a function is not usable outside that function. a. True b. False

True

After the statements: inct cont i=4; i++; the value of i is incremented a. True b. False

True

C++ is Strongly-typed a. True b. False

True

When does the code block following while(x<=100) execute? A. When x is less than one hundred B. When x is greater than one hundred C. When x is equal to one hundred D. While it wishes

When x is less than one hundred When x is equal to one hundred

Which one of the following notation comapres two variable X and Y a. X=Y b. X!=Y c. X equals Y d. X==Y

X==Y

What does this instruction sizeof(int); return? a. return the value of int b. return how much memory is allocated for int c. return the maximum capacity of int d. It does nothing

return how much memory is allocated for int

Which is more effective while calling the functions? a) call by value b) call by reference c) call by pointer d) none of the mentioned

call by reference

Where does the return statement returns the execution of the program? a) main function b) caller function c) same function d) none of the mentioned

caller function

sqrt requires the library: a. stdlib b. cmath c. console d. iomanip

cmath

Examine the following code: int count = 1; while ( ___________ ) { cout<<( count + " " ); count ++; } What condition should be used so that the code writes out: 1234567 8 A. count < 8 B. count < 9 C. count+1 <= 8 D. count != 8

count <9

Which looping process checks the test condition at the end of the loop? A. for B. while C. do-while D. no looping process checks the test condition at the end

do-while

Which loop is correct? A. do {//code}while (condition); B. do {//code}while (condition) C. do {//code}while (condition):

do{//code}while (condition);

Which looping process is best used when the number of iterations is known? A. for B. while C. do-while D. all looping processes require that the iterations be known

for

Which for loop is correct? A. for {i=0,i<10,i++} B. for (i=0; i<10; i++); C. for (i=0; i<10; i++) D. none of them

for (i=0;i<10;i++)

which for loop will not work? A. for (i=0; i<5; i++) B. for (i=5; i<=10; i++) C. for (i=5; i=10; i++)

for (i=5;i=10;i++)

What are mandatory parts in function declaration? a) return type, function name b) return type, function name, parameters c) both a and b d) none of the mentioned

return type, function name

The function call below is designed to return the product of x and y. All the variables are of type int. What is the correct prototype for such a function? myFunction(result, x, y); A. void myFunction(int, int) ; B. int myFunction(int, int) ; C. void myFunction(int, int, int) ; D. int myFunction(int, int, int)

int myFunction(int,int);

to use setprecision, you need to include: a. stdlib.h b. iomanip.h c. console.h d. conio.h

iomanip.h

Each pass through a loop is called a/an A. enumeration B. iteration C. culmination D. pass through

iteration

Where does the execution of the program starts? a) user-defined function b) main function c) void function d) none of the mentioned

main function

what is the function that all c++ programs must have a. start() b. system() c. main() d. program()

main()

In C++, the % refers to a. percentages b. modulus operator c. division d. data storage

modulus operator

whcih one of the following types can not hold the value 2.4 a. short b. float c. long double d. double

short

What is wrong with the following while loop? while ( sum <= 1000 ) sum = sum - 30; A. The parentheses should be braces B. Braces are required around sum = sum - 30; C. There should be a semicolon after while ( sum <= 1000 ) D. sum = sum - 30 should be sum = sum + 30 or else the loop may never end

sum = sum - 30 should be sum = sum + 30 or else the loop may never end

In a group of nested loops, which loop is executed the most number of times? A. the outermost loop B. the innermost loop C. all loops are executed the same number of times D. cannot be determined without knowing the size of the loops

the innermost loop

A continue statement causes execution to skip to A. the return 0; statement B. the first statement after the loop C. the statement following the continue statement D. the next iteration of the loop

the next iteration of the loop

What are opening and closing signs to signal the start and end of code blocks? a. (and) b. -> and <- c. BEGIN and END d. {}

{}


संबंधित स्टडी सेट्स

Comboset 5 -(C228) ATI-Community Health <Tests & Vocab>

View Set

Florida Statutes, Rules, and Regulations Common to All Lines QUIZ

View Set

CHAPTER 16 CHILD AND ADOLESCENT DISORDERS

View Set

Intermediate Accounting 3303 Chap 6

View Set

NU272 Week 6 EAQ Evolve Elsevier: Professionalism, Health, Wellness, Illness, Caring

View Set

Chapter 28: Safety, Security, and Emergency Preparedness

View Set

ATI - PME The Neurological System (Part 1)

View Set

Six Principles of Critical Thinking

View Set