Question 1
Identify the correct statement
a. Programmer can use comments to include short explanations within the source code itself.
b. All lines beginning with two slash signs are considered comments.
c. Comments very important effect on the behaviour of the program
d. both
Question 2
The directives for the preprocessors begin with
a. Ampersand symbol (&
b. Two Slashes (//)
c. Number Sign (#)
d. Less than symbol (<
Question 3
The file iostream includes
a. The declarations of the basic standard input-output library.
b. The streams of includes and outputs of program effect.
c. Both of these
d. None of these
Question 4
There is a unique function in C++ program by where all C++ programs start their execution
a. Start()
b. Begin()
c. Main()
d. Output()
Question 5
Every function in C++ are followed by
a. Parameters
b. Parenthesis
c. Curly braces
d. None of these
Question 6
Which of the following is false?
a. Cout represents the standard output stream in c++.
b. Cout is declared in the iostream standard file
c. Cout is declared within the std namespace
d. None of above
Question 7
Every statement in C++ program should end with
a. A full stop (.)
b. A Comma (,)
c. A Semicolon (
d. A colon (
Question 8
Which of the following statement is true about preprocessor directives?
a. These are lines read and processed by the preprocessor
b. They do not produce any code by themselves
c. These must be written on their own line
d. They end with a semicolon
Question 9
A block comment can be written by
a. Starting every line with double slashes (//)
b. Starting with /* and ending with */
c. Starting with //* and ending with *//
d. Starting with <!- and ending with -!>
Question 10
When writing comments you can
a. Use code and /* comment on the same line
b. Use code and // comments on the same line
c. Use code and //* comments on the same line
d. Use code and <!- comments on the same line
Question 1.
What is the correct value to return to the operating system upon the successful completion of a program?
A. -1
B. 1
C. 0
D. Programs do not return a value.
Question 2.
What is the only function all C++ programs must contain?
A. start()
B. system()
C. main()
D. program()
Question 3.
What punctuation is used to signal the beginning and end of code blocks?
A. { }
B. -> and <-
C. BEGIN and END
D. ( and )
Question 4.
What punctuation ends most lines of C++ code?
A. . (dot)
B. ; (semi-colon)
C. : (colon)
D. ‘ (single quote)
Question 5.
Which of the following is a correct comment?
A. */ Comments */
B. ** Comment **
C. /* Comment */
D. { Comment }
Question 6.
Which of the following is not a correct variable type?
A. float
B. real
C. int
D. double
Question 7.
Which of the following is the correct operator to compare two variables?
A. :=
B. =
C. equal
D. ==
Question 8.
Which of the following is true?
A. 1
B. 66
C. .1
D. -1
E. All of the above
Question 9.
Which of the following is the boolean operator for logical-and?
A. &
B. &&
C. |
D. |&
Question 10.
Evaluate !(1 && !(0 || 1)).
A. True
B. False
C. Unevaluatable
Question 1:
A function can not be overloaded only by its return type.
a. True
b. False
Question 2:
A function can be overloaded with a different return type if it has all the parameters same.
a. True
b. False
Question 3:
Inline functions involves some additional overhead in running time.
a. True
b. False
Question 4:
A function that calls itself for its processing is known as
a. Inline Function
b. Nested Function
c. Overloaded Function
d. Recursive Function
Question 5:
We declare a function with ______ if it does not have any return type
a. long
b. double
c. void
d. int
Question 6:
Arguments of a functions are separated with
a. comma (,)
b. semicolon (
c. colon (
d. None of these
Question 7:
Variables inside parenthesis of functions declarations have _____ level access.
a. Local
b. Global
c. Module
d. Universal
Question 8:
Observe following function declaration and choose the best answer:
int divide ( int a, int b = 2 )
a. Variable b is of integer type and will always have value 2
b. Variable a and b are of int type and the initial value of both variables is 2
c. Variable b is international scope and will have value 2
d. Variable b will have value 2 if not specified when calling function
Question 9:
The keyword endl
a. Ends the execution of program where it is written
b. Ends the output in cout statement
c. Ends the line in program. There can be no statements after endl
d. Ends current line and starts a new line in cout statement.
Question 10:
Strings are character arrays. The last index of it contains the null-terminated character
a. \n
b. \t
c.
d. \1
Question 1:
The void specifier is used if a function does not have return type.
a. True
b. False
Question 2:
You must specify void in parameters if a function does not have any arguments.
a. True
b. False
Question 3:
Type specifier is optional when declaring a function
a. True
b. False
Question 4:
Study the following piece of code and choose the best answer
int x=5, y=3, z;
a=addition(x,y)
a. The function addition is called by passing the values
b. The function addition is called by passing reference
Question 5:
In case of arguments passed by values when calling a function such as z=addidion(x,y),
a. Any modifications to the variables x & y from inside the function will not have any effect outside the function.
b. The variables x and y will be updated when any modification is done in the function
c. The variables x and y are passed to the function addition
d. None of above are valid.
Question 6:
If the type specifier of parameters of a function is followed by an ampersand (& , that function call is
a. pass by value
b. pass by reference
Question 7:
In case of 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 above
Question 8:
Overloaded functions are
a. Very long functions that can hardly run
b. One function containing another one or more functions inside it.
c. Two or more functions with the same name but different number of parameters or type.
d. None of above
Question 9:
Functions can be declared with default values in parameters. We use default keyword to specify the value of such parameters.
a. True
b. False
Question 10:
Examine the following program and determine the output
#include <iostream>
using namespace std;
int operate (int a, int b)
{
return (a * b);
}
float operate (float a, float b)
{
return (a/b);
}
int main()
{
int x=5, y=2;
float n=5.0, m=2.0;
cout << operate(x,y) <<”\t”;
cout << operate (n,m);
return 0;
}
a. 10.0 5.0
b. 5.0 2.5
c. 10.0 5
d. 10 2.5
Question 1:
Find out the error in following block of code.
If (x = 100)
Cout << “x is 100”;
- 100 should be enclosed in quotations
- There is no semicolon at the end of first line
- c. Equals to operator mistake
- Variable x should not be inside quotation
Question 2:
Looping in a program means
- Jumping to the specified branch of program
- b. Repeat the specified lines of code
- Both of above
- None of above
Question 3:
The difference between while structure and do structure for looping is
- In while statement the condition is tested at the end of first iteration
- In do structure the condition is tested at the beginning of first iteration
- The do structure decides whether to start the loop code or not whereas while statement decides whether to repeat the code or not
- d. In while structure condition is tested before executing statements inside loop whereas in do structure condition is tested before repeating the statements inside loop
Question 4:
Which of the following is not a looping statement in C?
- while
- b. until
- do
- for
Question 5:
Which of the following is not a jump statement in C++?
- break
- goto
- exit
- d. switch
Question 6:
Which of the following is selection statement in C++?
- break
- goto
- exit
- d. switch
Question 7:
The continue statement
- resumes the program if it is hanged
- resumes the program if it was break was applied
- c. skips the rest of the loop in current iteration
- all of above
Question 8:
Consider the following two pieces of codes and choose the best answer
Code 1:
switch (x) {
case 1:
cout <<”x is 1”;
break;
case 2:
cout <<”x is 2”;
break;
default:
cout <<”value of x unknown”;
}
Code 2
If (x==1){
Cout <<”x is 1”;
}
Else if (x==2){
Cout << “x is 2”;
}
Else{
Cout <<”value of x unknown”;
}
- a. Both of the above code fragments have the same behaviour
- Both of the above code fragments produce different effects
- The first code produces more results than second
- The second code produces more results than first.
Question 9:
Observe the following block of code and determine what happens when x=2?
switch (x){
case 1:
case 2:
case 3:
cout<< “x is 3, so jumping to third branch”;
goto thirdBranch;
default:
cout<<”x is not within the range, so need to say Thank You!”;
}
- Program jumps to the end of switch statement since there is nothing to do for x=2
- The code inside default will run since there is no task for x=2, so, default task is run
- c. Will display x is 3, so jumping to third branch and jumps to thirdBranch.
- None of above
Question 10
Which of the following is false for switch statement in C++?
- It uses labels instead of blocks
- we need to put break statement at the end of the group of statement of a condition
- c. we can put range for case such as case 1..3
- None of above
Disclaimer:- Source can be : Mcqs On Computer By : Dr. Alok Kumar or psexam.com (I am not sure about it; I compiled it and converted in better format for my own study; Just sharing in case anyone finds it useful; don’t want to take credit from the original author)