COMSC Quiz Qs

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

What is the value in ans from the following statements? int a = 5, b = 9, c = 7; double ans; ans = a % (b - c) / 4;

0

How many bytes in one bool data type variable?

1

What is assigned to the variable result given the statement below with the following assumptions: x = 10, y = 7 x, result, and y are all int variables. result = x >= y;

1

What will be displayed after the following statements execute? int funny = 7, serious = 15; funny = serious % 2; if (funny != 1) { funny = 0; serious = 0; } else if (funny == 2) { funny = 10; serious = 10; } else { funny = 1; serious = 1; } cout << funny << " " << serious << endl;

1 1

What is the value of donuts after the following statement executes? int donuts = 10; if (donuts != 10) donuts = 0; else donuts += 2;

12

After the following code executes, what is the value of my_value if the user enters 0? cin >> my_value; if (my_value > 5) my_value = my_value + 5; else if (my_value > 2) my_value = my_value + 10; else my_value = my_value + 15;

15

Which one below is an invalid identifier? price_1, _price, price_, 1price

1price

What is the value held in the variable, ratio? int length = 12, width = 5, ratio; ratio = 12/5;

2

Which is the output from the following statement? #include <iostream> using namespace std; int main() { cout << sizeof(int) << endl; return 0; }

4

How many bytes of memory for an int variable?

4 bytes

How many bits in one byte?

8

What is the return value from the following statement? pow(2, 3);

8.0

To generate a random integer value with the rand() function, which library should be included?

<cstdlib>

In order to call the setw() function, which library below should be included?

<iomanip>

Which C++ default library should be included before using cout ( for the console output) object.

<iostream>

To define a C++ string, which library below should be included?

<string>

The __________ is an equality (or comparison) operator. =, == , !=, >=

>=

Which one below is NOT a valid relational operator in C++? >>, != , > , == , <

>>

Which of the following assignment statements is incorrect? A. i = 1 = j = 1 = k = 1; B. i = 1; j = 1; k = 1; C. i = 1; j = 1; k = 1; D. i = j = k = 1;

A

Which one below is NOT a logical operator: A. != B. && C. || D. !

A

Which one is a ternary operator in C++? A. ? : B. *% C. ? : : D. :?

A

Arithmetic & Logic Unit (ALU) resides in ___________. A. Random Access Memory (RAM) B. Central Processing Unit (CPU) C. Hard Drive D. All answers are correct

B

What IDE below we did NOT introduce to run C++ programs in this course? A. XCode B. Eclipse C. CLoud9 D. Visual Studio E. CodeBlocks

B

Which one below is NOT possible to return from the following statement: cout << rand() % 10 << endl; A. 8 B. 12 C. 9 D. 0

B

Microsoft Word is a(n) ___________________. A. software development B. operating system software C. application software D. utility program software

C

Which one below is a correct way to declare a char variable and assign a value to it? A. char a="A"; B. char a = AA; C. char a = 'A'; D. char a = A;

C

Which programming language is NOT a high level language? A. C B. PYTHON C. Assembly Language D. C++ E. JAVA

C

Which statements below is valid? A. char letter = "a"; B. int number 1 = 100; C. const auto PI = 3.14159L; D. const double PI ;PI = 3.14159;

C

Which is NOT an operator in C++? A. % B. + C. * D. #

D

Which of the following expression results in a value 1? A. 2%1 B. 25%5 C. 15%4 D. 37%6

D

Which programming language is NOT an Object-Oriented programming? A. PYTON B. JAVA C.C++ D. FORTRAN

D

int count = 10; Which statement does NOT decrease the variable count by 1? A. count -= 1; B. int x = count - 1; count = x; C. count = count - 1; D. count =- 1;

D

What is the result from the following statement? 'A' > 'Z';

False

What is the result from the following statement? int x = 5, y = 6; x >= y

False

The conditional operator takes two operands.

False (3)

What is the output of the following code segment if the user enters 35? int number; cout << "Enter a number: "; cin >> number; if (number > 0) cout << "Hi, there!" << endl; else cout << "Good-bye." << endl;

Hi, there!

Which library needs to be included to use the casting operator, static_cast ?

No library required

What will be displayed in the console from the following statement? int x = 5; if ( x == 5) cout << "TRUE" << endl; else cout << "FALSE" << endl;

TRUE

If x = 5 and y = 10, what is the result from the following statement? if (x == y) cout << "Two values are the same!" << endl; else { if (x > y) cout << "That's true!" << endl; else cout << "That's false!" << endl; }

That's false!

The value of a conditional expression ( ? : ) is ?

The first condition is to be tested

What is the output of the following code segment? int x = 5; if (x == 2) cout << "This is true!" << endl; else cout << "This is false!" << endl; cout << "That's all, folks!" << endl;

This is false! That's all, folks!

Both of the following if statements perform the same operation.(T/F) //# 1 if (sales > 10000) commissionRate = 0.15; //#2 if (sales > 10000) commissionRate = 0.15;

True

If x = 10, y = 8. The statements below will be (T/F): x > y && x != y

True

In C++ 11 and above, we can use the auto keyword to define a variable as below. The compiler will automatically to assign the variable as long long int type. auto number = 120LL;

True

We can use cin object to store values into multiple variables in one single statement. For example: (T/F) double length, width, area; cin >> length >> width >> area;

True

What is the result from the following statement? "Mary" > "Mark";

True

What is the result from the following statement? '9' > '2';

True

What is the output of the following code segment if the user enters 90 for the score? cout << "Enter your test score: "; cin >> test_score; if (test_score < 60) cout << "You failed the test." << endl; if (test_score > 60) cout << "You passed the test." << endl; else cout << "You need to study harder next time." << endl;

You passed the test

Convert the following if-else statements to a statement including conditional operator: if ( age >= 18) string1 = "adult"; else string1 = "child";

age >= 18 ? string 1 = "adult" : string 1 = "child";

In a switch (expression) statement, which keyword used to check the different expression value?

case

What function does this describe: read the next byte from the input buffer

cin.get(n)

What function does this describe: skip the next byte in the input buffer

cin.ignore(n)

Relational operators allow you to __________ numbers.

compare

Which is not a keyword in C++? return, int, double, using, cout

cout

The file extension for a source file in C++ is ______.

cpp

If you intend to place a block of statements within an if statement, you must place __________ around the block:

curly braces {}

Variables defined inside _________ have local or block scope

curly braces {}

What is the data type from the expression, a + b, from the following statements? int a = 5; double b = 8.1; cout << a + b << endl;

double

Which procedure below is the steps to make a source file to be run on IDEs? Put the following in order: Edit the source file, run the preprocessor, run the compiler, run the linker, produce an executable file

edit the source file, run the preprocessor, run the compiler, run the linker, produce an executable file

By the given the values below, what is the result from the boolean expression: int x = 12, y = 5, z = -4; !( y >= z);

false

Is this a valid C++ statement : int a, b, c, double d;

false

What function does this describe: display floating number in fixed point notation instead of the scientific notation

fixed

Which one below is NOT used to declare a floating-point variable? double a, long long int c, long double b, float f

long long int c;

Which one below is NOT a keyword in C++? bool, break, longlong, return, int

longlong

When an if statement is placed within the conditionally-executed code of another if statement, this is known as

nesting

which statement below used to to set the number of digits in decimal to display?

setprecision( )

What function does this describe: set the n decimal digits for all floating numbers

setprecision(n)

What function does this describe: print the following field in n spaces

setw(n)

What function does this describe: initialize random number generator with n

srand(n)

By the given the values below, what is the result from the boolean expression: int x = 12, y = 5, z = -4; ( x < y ) || ( y != z);

true

By the given the values below, what is the result from the boolean expression: int x = 12, y = 5, z = -4; ( x >= y ) && ( y >= z);

true

Is the following statements valid? int a = 5; int sum = 82; double average = (double) 82 / 5;

true

The default keyword is optional in a switch statement but highly recommended to include.

true

The value of result in the following expression will be 0 if x has the value of 20. result = x > 100 ? 0 : 1;

true

Which one below is NOT a C++ keyword: variable, return, double, short

variable

Write a C++ expression with a math function for y = x4 (assume both y and x are double variables, and <cmath> library is included)

y = pow(x, 4);


Set pelajaran terkait

English 12A - Unit Three: Going Green and Clean

View Set

Abeka 7th grade Of People Test 6/Semester Exam

View Set

A Man for All Seasons Quotes Order

View Set

The Capybara with Boots - Ch 9-10 Story Questions

View Set

molecular genetics module 3 exam

View Set