Multiple Choice Questions Flashcards
(117 cards)
. ________ is the physical aspect of the computer that can be seen
a) hardware
b) Software
c) Operating system
d) Application programming
Hardware
some hardware components of a computer include: CPU, memory, hard disk, printer, and communication devices
__________ is the brain of a computer.
a) Hardware
b) CPU
c) Memory
d) Disk
CPU
the CPU retrieves instructions from the memory and executes them
One byte has __ bits
a) 4
b) 8
c) 12
d) 16
8
A computers _____ is volatile; that is, any information stored in it is lost when the systems power is turned off
a) Floppy disk
b) Flashdisk
c) CD-ROM
d) memory
Memory
The memory of the computer is used to store data and program instructions for the CPU to execute. The memory is volatile, so when power is turned off information is lost. That is why information is stored in storage devices.
Computers can execute the code in ______
a) machine language
b) assembly language
c) high-level language
d) none of the above
Machine Language
Machine language is a computers native language, a set of built in primitive instructions
ex. adding two numbers would look something like
1101101010011010
_____ translates high level language program into machine language program
a) An assembler
b) A compiler
c) CPU
d) the operating system
A compiler
_____ is an operating system
a) Java
b) C++
c) Windows
d) Visual basics
Windows
An operating system is an important program that manages and controls a computers activities
_______ is a program that runs on a computer to manage and control a computers activities
a) Operating System
b) C++
c) interpreter
d) Complier
Operating System
an example of an operating system is Windows
Which of the following statements is the correct way to displau Welcome to C++ on the console?
A) cout «_space;“Welcome to C”;
B) cout»_space; “Welcome to C”;
C) cout < “Welcome to C”;
D) cout «_space;‘Welcome to C’
cout «_space;“Welcome to C”;
Which of the following preprocessor directive is correct?
A) import iostream
B) #include <iostream>
C) include <iostream>
D) #include iostream</iostream></iostream>
include <iostream></iostream>
a compiler preprocessor directive that tells the compiler to include the iostream library in the program. It is needed to support console input and output
Every statement in C ends with ________, which is called a statement terminator
A) a semicolon (;)
B) a comma (,)
C) a peiod (.)
D) an asteisk (*)
A semicolon ;
a statement is a complete and separate instruction that preforms some action.
A block is enclosed inside __________.
A) Parentheses
B) Braces
C)Brackets
D) Quotes
Braces
a block is a set of statements that are grouped together and treated as one unit
Which of the following statements is correct?
A) Every line in a program must end with a semicolon
B) Every statement in a program must end with a semicolon
C) Every comment line must end with a semicolon
D) Every function must end with a semicolon
E) Every preprocessor directive must end with a semicolon
Every statement in a program must end with a semicolon
What is the output of the following code?
cout «_space;“1 + 2 +3” «_space;endl;
cout «1 +2 +3 «_space;endl;
A) 1 + 2 + 3 followed by 6
B) “6” followed by 6
C) 1 + 2 + 3 followed by 1 + 2 + 3
D) 6 followed by 6
1 + 2 + 3 followed by 6
cout «_space;“1 + 2+ 3” «_space;endl;
cout «_space;1 +2 + 3 «_space;endl;
anything in quotation marks is displayed exactly as seen.
Since the next line is not in quotation marks, it will be calculated and the answer will be displayed.
___________ is called a stream insertion operator for sending output to the console.
A) a semicolon (;)
B) a comma (,)
C) a peiod (.)
D) an asteisk (*)
E) «
«
The «_space;is used to insert data into the output stream.
C++ compiler translates C++ source code into _________.
A) Java code
B) machine code
C) C code
D) another high-level language code
Machine code
The computer can only read machine code, so the compiler takes everything in C++ language and translates it into machine language so the computer can execute it.
Suppose you create a C as follows, the source code should be stored in a file named ___________.
int main()
{
}
A) Test.cpp
B) Test.doc
C) Test.txt
D) Test.java
E) Any name with extension .cpp
Any name with extension .cpp
When naming the source code it is really only being named for your use. You can call it anything you want, just maker sure it is followed by .cpp
If a program compiles fine, but it produces incorrect result, then the program suffers
__________.
A) a compilation/syntax eror
B) a runtime eror
C) a logic error
a logic error
A logic error is when the program does not run the way it was intended. These errors are really hard to identify.
include <iostream></iostream>
The following code has _______.
using namespace std;
int main()
{
cout «_space;“Welcome to C++ «_space;endl;
return 0;
}
A) a compilation/syntax eror
B) a runtime eror
C) a logic error
A compilation/ syntax error
A compiler/ syntax error is one detected by the compiler. You can see that there is a missing quotation mark, a mistake made by the programmer.
____________ is the assignment operator.
A ==
B :=
C =
D =:
=
the assignment operaotr is used to assign a value to a variable.
ex.
int x=5
the assignment operator is used to assign the value of 5 to the variable x
To assign a value 1 to variable x, you write
1 = x;
B x = 1;
C x := 1;
D 1 := x;
E x == 1;
x=1;
Which of the following types can be used to define a floating-point numbers?
A) int
B) shot
C) long
D) double
double
use when the variable can be a decimal number
To improve readability and maintainability, you should declare a _________ for PI instead of
using literal values such as 3.14159.
A) variable
B) function
C) constant
D) class
constant
declaring a constant allows you to create a value that cannot be changed throughout the program.
ex. declaring a constant for pi
const double pi = 3.14159;
now, anytime you use pi in your program its value that was initialized will be used.
To declare a constant MAX_LENGTH inside a function with value 99.98, you write
A)const MAX_LENGTH = 99.98;
B) double MAX_LENGTH = 99.98;
C) const double MAX_LENGTH = 99.98;
const double MAX_LENGTH = 99.98;
this statement is declaring a constant variable called MAX_LENGTH. This number will stay the same throughout the entire program i=since it is a constant. It can also be a decimal number since it is a double type