CS201 MCQs Mids 2024 Mam Mehwish

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 53

PAID VU LMS HANDLING by Mam Mehwish

03184148783
Past Papers for Mids./Finals are also Available

1. The result of 4 % 3 will be

Options:

A) 1

B) 2

C) 3

D) 0

Correct Option: A) 1

2. While loop executes at least ______ if the condition is false.

Options:

A) One time

B) Undefined times

C) Two times

D) Zero time

Correct Option: D) Zero time

3. Compiler translates high level language program into _________ language code.

Options:

A) Source

B) Machine

C) Assembly

D) Object

Correct Option: B) Machine


4. Computers can understand only __________ language code.

Options:

A) Source

B) Machine

C) Human-readable

D) Assembly

Correct Option: C) Machine

5. When the if statement consists of more than one statement then enclosing these statement in braces
is _________.

Options:

A) Compulsory

B) Relevant

C) Optional

D) Not required

Correct Option: A) Compulsory

6. If a function has not been declared before its definition, it is a _______.

Options:

A) Compilation error

B) Late binding error

C) Logical error

D) Run-time error

Correct Option: A) Compilation error

7. What will be the output of the following program?

```

void car() {

cout << "Honda";


}

int main() {

Car();

```

Options:

A) Compilation error

B) Honda

C) Runtime error

D) Undefined behavior

Correct Option: A) Compilation error

8. What is the output of the following code, if the first case is true

```

switch (var)

case 'a':

cout<<”apple”<<endl;

case 'b':

cout<<”banana”<<endl;

case 'm':

cout<<”mango”<<endl;

default:

cout<<”any fruit”<<endl;

```

Options:

A) apple

B) apple, banana, mango, any fruit


C) Compilation error

D) banana, mango, any fruit

Correct Option: B) apple, banana, mango, any fruit

9. ” = “ operator is used for ___________.

Options:

A) Check equality

B) Check inequality

C) Assigning value

D) Calculating value

Correct Option: C) Assigning value

10. To perform repetition tasks for a known number of repetitions, most often used structure is
__________.

Options:

A) While structure

B) For structure

C) Do-while structure

D) None of the above

Correct Option: B) For structure

1. If a function has not been declared before its definition, it is a:

- a) logical error

- b) run time error

- c) Late binding error

- d) Compilation error

- Correct option: d) Compilation error

2. The data type before a function name represents its:


- a) Function arguments

- b) Function arguments

- c) Function name

- d) Function data

- Correct option: c) Function name

3. C was developed with the help of _____________ language(s).

- a) JAVA

- b) BCPL and BFORTRAN

- c) C#

- d)

- Correct option: b) BCPL and BFORTRAN

4. Which of the following is the right syntax to declare a variable in C++?

- a) DataType = VariableName;

- b) (DataType) VariableName;

- c) VariableName Datatype;

- d) DataType VariableName;

- Correct option: d) DataType VariableName;

5. The name of a location in memory is called ____________.

- a) Variable

- b) Number

- c) Constant

- d) Cell

- Correct option: a) Variable

6. What will be the result of the expression `k = ++m;` if initially `k = 0` and `m = 5`?

- a) 5
- b) 6

- c) 7

- d) 4

- Correct option: b) 6

7. When we call a function, its control___________.

- a) The compiler stops execution of the whole program

- b) Returns to statement following function call

- c) Transfers to its definition

- d) Transfers to its definition

- Correct option: c) Transfers to its definition

8. It is the job of ________ to transfer the executable code from hard disk to main memory.

- a) Linker

- b) Debugger

- c) Loader

- d) Interpreter

- Correct option: c) Loader

9. What is the output of the following code, if the first case is true:

```cpp

switch (var)

case 'a':

cout<<”apple”<<endl;

case 'b':

cout<<”banana”<<endl;

case 'm':

cout<<”mango”<<endl;
default:

cout<<”any fruit”<<endl;

```

- a) apple

- b) banana

- c) mango

- d) any fruit

- Correct option: d) any fruit

10. __________ of a variable means the locations within a program from where it can be accessed.

- a) Reference

- b) Value

- c) Data type

- d) Visibility

- Correct option: d) Visibility

1. Correcting the errors from a program is termed as __________.

- a) Debugging

- b) Executing

- c) Loading

- d) Linking

- Correct option: a) Debugging

2. The expression ((a + b) == 10) && ((x + y) == 20) is true only if __________________.

- a) Either ((a + b) == 10) or ((x + y) == 20) is true

- b) Both ((a + b) == 10) and ((x + y) == 20) are true

- c) ((x + y) == 20) is true

- Correct option: b) Both ((a + b) == 10) and ((x + y) == 20) are true
3. If x is declared as an integer, what will be the result of the given expression?

x=3*5%(2+2)/2

- a) 1

- b) 2

- c) 3

- d) 4

- Correct option: a) 1

4. < , <= , > , >= are called __________ operators.

- a) Relational

- b) Logical

- c) Arithmetic

- d) Assignment

- Correct option: a) Relational

5. __________ explain the functionality of a program.

- a) Linker

- b) Comments

- c) Compiler

- d) Debugger

- Correct option: c) Compiler

6. Compiler translates high-level language program into _________ language code.

- a) Assembly

- b) Machine

- c) Binary

- d) Low-level

- Correct option: b) Machine


7. Loops are _______________ Structure.

- a) Control

- b) Sequence

- c) Repetition

- d) Selection

- Correct option: c) Repetition

8. Loops are _______________ Structure.

- a) Control

- b) Sequence

- c) Repetition

- d) None of the given options

- Correct option: c) Repetition

9. __________ will be used for enclosing function statements into a block.

- a) Parentheses

- b) Brackets

- c) Semicolon

- d) Braces or curly braces '{}'

- Correct option: d) Braces or curly braces '{}'

10. What will be the resultant value of this expression x = 17 % 3 ?

- a) 0

- b) 1

- c) 2

- d) 3

- Correct option: c) 2
11. _________ stops execution at the line that contains error(s) in the code.

- a) Debugger

- b) Linker

- c) Compiler

- d) Interpreter

- Correct option: a) Debugger

1. Which of the following loops checks the test condition at the end of the loop?

Options:

A) While

B) For

C) Nested Loop

D) Do-While

Correct Option: D) Do-While

2. According to C++ norms; the first character of a variable name must be an alphabet or ________.

Options:

A) Underscore

B) Special character

C) UnderscoreSpecial character

D) Special characterUnderscore

Correct Option: A) Underscore

3. We use ________ to control our program while it is running.

Options:

A) Debugging

B) Programming

C) Compilation

D) Execution
Correct Option: A) Debugging

4. If we pass more than one argument to a function then they are separated by ________.

Options:

A) Commas

B) Semicolons

C) Colons

D) Spaces

Correct Option: A) Commas

5. If j = 10 and x = ++j, then the value of x will be ________.

Options:

A) 9

B) 10

C) 11

D) 12

Correct Option: C) 11

6. Identify the logical error in the following if condition:

If ((i < 5) && (i > 15))

Options:

A) `&` will be used instead of `&&`

B) `&&` cannot be used with if condition

C) Condition is always true

D) Condition is always false

Correct Option: D) Condition is always false

7. The result of 4 % 3 will be ________.

Options:
A) 0

B) 1

C) 2

D) 3

Correct Option: B) 1

8. ________ will be used for enclosing function statements into a block.

Options:

A) Parentheses

B) Curly braces {}

C) Square brackets []

D) Angle brackets <>

Correct Option: B) Curly braces {}

9. The most suitable data type for the number 325.25 is ________.

Options:

A) int

B) char

C) short

D) float

Correct Option: D) float

10. Which of the following is not a subcategory of the system software?

Options:

A) Application software

B) Operating system

C) Utilities

D) Device drivers

Correct Option: A) Application software


1. In C/C++, a variable’s name can start with the symbol:

- a) #

- b) $

- c) _

- d) @

- Correct option: c) _

2. _________ of a variable means the locations within a program from where it can be accessed.

- a) Data type

- b) Reference

- c) Value

- d) Visibility

- Correct option: d) Visibility

3. Modulus operator (%) is only used with ____________ type of operands.

- a) Integer

- b) Float

- c) Character

- d) String

- Correct option: a) Integer

4. Which of the following is the right syntax to declare a variable in C++?

- a) DataType = VariableName;

- b) (DataType) VariableName;

- c) VariableName DataType;

- d) DataType VariableName;

- Correct option: d) DataType VariableName;


5. C was developed with the help of _____________ language(s).

- a) C#

- b) JAVA

- c) JAVA

- d) FORTRAN, BCPL, and B

- Correct option: d) FORTRAN, BCPL, and B

6. In the following nested For Loop, which loop will run most number of times?

```c

for( int i = 0; i < 5; i++) {

for(int k = 0; k < 5; k++) {

// ......

```

- a) The outer loop

- b) The inner loop

- c) Both will run the same number of times

- d) None will run

- Correct option: b) The inner loop

7. We use ____________ to control our program while it is running.

- a) Loader

- b) Compiler

- c) Debugger

- d) Linker

- Correct option: c) Debugger

8. If a function has not been declared before its definition, it is a ----------.


- a) logical error

- b) Compilation error

- c) Run-time error

- d) Late binding error

- Correct option: b) Compilation error

1. Operating System is a type of ___________ software.

Options:

a) Application

b) Device Driver

c) Utility

d) System

Correct option: d) System

2. When we call a function, its control___________.

Options:

a) The compiler stops execution of whole program

b) Transfers to its Prototype

c) Transfers to its definition

d) Returns to statement following function call

Correct option: d) Returns to statement following function call

3. Computers can understand only __________ language code.

Options:

a) Human

b) High-level

c) Assembly

d) Machine

Correct option: d) Machine


4. In while loop the condition is checked __________ the execution of loop.

Options:

a) During

b) After

c) Before

d) Along with

Correct option: c) Before

5. && is a ___________ operator.

Options:

a) Bitwise

b) Logical

c) Relational

d) Arithmetic

Correct option: b) Logical

6. In switch statement there can be _______ default statement(s).

Options:

a) None

b) One

c) Two

d) Many

Correct option: b) One

7. MS Word is a type of ___________ software.

Options:

a) Application

b) Utility
c) System

d) Device Driver

Correct option: a) Application

8. If int a = 50; then the value of a/= 3; will be,

Options:

a) 16

b) 17

c) 15

d) 51

Correct option: a) 16

9. For the following given function prototype,

int add (int *);

which one of the given function calls is “call by reference”?

Options:

a) add(num);

b) add(&num);

c) add(*num);

d) add(*&num);

Correct option: b) add(&num);

10. X is an integer variable; what does X++ means,

Options:

a) Add 2 in X value

b) Add 1 two times in X value

c) None of these

d) Add 1 in X value

Correct option: d) Add 1 in X value


1. Which of the following is the correct operator to compare the values of two variables?

- A) *=

- B) =

- C) ==

- D) ===

- Correct Option: C) ==

2. If j = 10 and x = ++j, then the value of x will be _____________.

- A) 9

- B) 10

- C) 11

- D) 12

- Correct Option: C) 11

3. What will be the result of the expression `k = ++m;`, if initially k = 0 and m = 5?

- A) 5

- B) 6

- C) 7

- D) 8

- Correct Option: B) 6

4. __________ will be used for clarity and to force the order of evaluation in an expression.

- A) Brackets {}

- B) Apostrophes ''

- C) Parentheses ()

- D) Quotation marks ""

- Correct Option: C) Parentheses ()


5. If int a = 50;, then the value of a /= 3; will be ___________.

- A) 14

- B) 15

- C) 16

- D) 17

- Correct Option: C) 16

6. While loop executes at least ______ if the condition is false.

- A) 0 times

- B) 1 time

- C) 2 times

- D) Infinite times

- Correct Option: A) 0 times

7. In do while loop, the condition is checked __________ one execution of loop.

- A) before

- B) after

- C) during

- D) parallel to

- Correct Option: B) after

8. !( x > 3) means in C++ that

- A) x is greater than 3

- B) x is less than or equal to 3

- C) x is not greater than 3

- D) x is not less than or equal to 3

- Correct Option: C) x is not greater than 3

9. We comment the code because it makes program __________________ .


- A) Complex to understand

- B) Difficult to compile

- C) Heavy i.e. more space is needed for executable

- D) Easy to understand

- Correct Option: D) Easy to understand

10. Switch statement can be used in place of _________ statement.

- A) continue

- B) break

- C) goto

- D) Multiple if

- Correct Option: D) Multiple if

1. Which of the following is one of the main categories of software?

- A) Device drivers

- B) Utilities

- C) Operating system

- D) System Software

- Correct Option: C) Operating system

2. What will be output of the following code segment?

```cpp

int value = 1;

switch (value+value){

case 1 :

cout << "Punjab " ;

break;

case 2 :

cout << "Lahore" ;


break;

default :

cout << "Pakistan" ; }

```

- A) Punjab

- B) Lahore

- C) Pakistan

- D) None of the above

- Correct Option: B) Lahore

3. In the given expression which operator will be evaluated first?

`10 + (6 / 2) – 2 * 3`

- A) Addition

- B) Division

- C) Multiplication

- D) Subtraction

- Correct Option: B) Division

4. What will be the values of variables x and y after executing the following code if x = 33 and y = 19?

```cpp

if(x % y != 0)

x++;

y--;

```

- A) x = 33, y = 19

- B) x = 34, y = 18

- C) x = 32, y = 20
- D) x = 34, y = 19

- Correct Option: B) x = 34, y = 18

5. From given options, select the correct syntax of the “function call” to the following function.

`float add (int &);`

- A) add(&x);

- B) add (*x);

- C) add(int x);

- D) add(x);

- Correct Option: D) add(x);

6. Which of the following is a reserved word for data types in C/C++?

- A) integer

- B) int

- C) character

- D) doubles

- Correct Option: B) int

7. What is the logical error in the following lines of code?

```cpp

if (x = 10)

cout << “x is 10”;

```

- A) Assignment operator should not be used for comparison

- B) There is no semicolon at the end of if condition

- C) Variable x should not be inside parenthesis

- D) 10 should be enclosed in quotations

- Correct Option: A) Assignment operator should not be used for comparison


8. _______ explain the functionality of a program.

- A) Debugger

- B) Comments

- C) Linker

- D) Compiler

- Correct Option: B) Comments

9. We can access a global variable ___________

- A) From anywhere in the program

- B) From the loops only

- C) From the main() function only

- D) From the functions only

- Correct Option: A) From anywhere in the program

10. What will be the correct output for the given program?

```cpp

int num = 1;

switch ()

case 1 :

cout << "15 " ;

break;

default :

cout << "20" ;

```

- A) 15

- B) 20

- C) Error: missing expression in switch statement


- D) None of the above

- Correct Option: C) Error: missing expression in switch statement

1. If j=10 and x = ++j, then the value of x will be _____________.

- a) 10

- b) 11 (Correct)

- c) 12

- d) 9

2. If we assign 2.06721 to an integer variable x, what will be the output if we print x using cout<<x;
statement?

- a) 2.06721

- b) 2.0

- c) 2 (Correct)

- d) 3

3. What will be the resultant value of this expression x = 17 % 3?

- a) 1

- b) 2 (Correct)

- c) 3

- d) 4

4. Which of the following is not a valid variable name in C++?

- a) _studentNameNameOfStudent

- b) NameOfStudent

- c) @studentName

- d) nameOfStudent (Correct)

5. Compiler translates high-level language program into _________ language code.


- a) Machine (Correct)

- b) Assembly

- c) Low-level

- d) Source

6. Remainder operator (%) is a/an __________ operator.

- a) Logical

- b) Arithmetic (Correct)

- c) Arithmetic

- d) Relational

7. A variable of character data type occupies ________ byte(s) in memory.

- a) 1 (Correct)

- b) 2

- c) 4

- d) 8

8. The ________ is an unconditional branch of execution.

- a) if statement

- b) while loop

- c) do-while loop

- d) goto (Correct)

9. Which of the following is not the subcategory of the system software?

- a) Device drivers

- b) Device drivers

- c) Device drivers (Correct)

- d) Operating system
10. While loop becomes infinite in which scenario _______.

- a) When the condition is always False (Correct)

- b) Condition contains logical operators

- c) Condition contains arithmetic operators

- d) None of the above

1. Why do we use "cin"?

- To display message

- To send data to printer

- To read data from keyboard (Correct)

- To display output on the screen

2. If we pass more than one argument to a function then they are separated by _________.

- Double quotes

- Colon

- Semicolon

- Comma (Correct)

3. Function prototype is written _______.

- Within the parentheses of main()

- After the return statement in main

- Before the return statement in main (Correct)

- Before the call of that function

4. We comment the code because it makes the program __________.

- Complex to understand

- Difficult to compile

- Easy to understand (Correct)

- Heavy i.e. more space is needed for the executable


5. Default mechanism of calling a function by passing it an array is call by ________ and in the case of
passing a variable is call by ________.

- Reference, Reference

- Value, Reference

- Reference, Value

- Call by reference, Call by value (Correct)

6. < , <= , > , >= are called ________ operators.

- Logical

- Relational (Correct)

- Conational

- Arithmetic

7. What will be the output for the following code segment?

```cpp

for ( int num = 3; num <= 5; num++ )

if ( num % 2 != 0)

continue;

cout << num << " ";

```

Options:

- 2 3 4 5'

- 2 3 4 5 (Correct)

-24

8. What logical error exists in the following arithmetic expression?


```cpp

X = 50 / ( 2 % 2 ) + 9

```

Options:

- Division by zero will occur in this expression (Correct)

- Order of the expression is not according to rules

- We cannot use % operator in expressions

- Parenthesis are not allowed in expressions

9. If x is declared as an integer, what will be the result of the given expression?

```cpp

x=3*5%(2+2)/2

```

Options:

- 0 (Correct)

-3

-1

-5

10. What will be the output of the following program?

```cpp

void car() {

cout << "Honda";

int main() {

Car();

```

Options:
- CarHonda

- Syntax Error (Correct)

- Honda

- Honda car

1. The result of 4 % 3 will be:

A. 1

B. 2

C. 0

D. 3

Correct Option: A. 1

2. According to C++ norms, the first character of a variable name must be an alphabet or ________.

A. Special character

B. Underscore

C. Digit

D. None of the given options

Correct Option: B. Underscore

3. We can access a global variable ________.

A. From the functions only

B. From the loops only

C. From anywhere in the program

D. From the main() function only

Correct Option: C. From anywhere in the program

4. ________ keyword is used to return some value from a function.

A. goto

B. break
C. return

D. None of these

Correct Option: C. return

5. In call by reference, ________ of a variable is passed to the called function.

A. value

B. name

C. address

D. None of these

Correct Option: C. address

6. Which step is not performed during a proper program design?

A. Write details about the performance of program

B. Analyze a problem statement, typically expressed as a word problem

C. Formulate statements and comments in a precise language

D. Pay attention to detail

Correct Option: A. Write details about the performance of program

7. X is an integer variable; what does X++ means?

A. Add 1 in X value

B. Add 1 two times in X value

C. None of these

D. Add 2 in X value

Correct Option: A. Add 1 in X value

8. If we pass more than one arguments to a function then they are separated by ________.

A. Period

B. Colon

C. Semicolon
D. Comma

Correct Option: D. Comma

9. A variable of character data type occupies ________ byte(s) in memory.

A. 2

B. 3

C. 1

D. 4

Correct Option: C. 1

10. In switch statement there can be ________ default statement(s).

A. 2

B. 1

C. 0

D. Many

Correct Option: B. 1

1. For breaking complex problems into smaller pieces we use _______.

- a) if

- b) else

- c) Functions

- d) Loops

- Correct option: c) Functions

2. If x = 11, and x %= 3, then value of x will be ___________.

- a) 0

- b) 1

- c) 2

- d) 3
- Correct option: c) 2

3. ________ of a variable means the locations within a program from where it can be accessed.

- a) Visibility

- b) Reference

- c) Value

- d) Data type

- Correct option: a) Visibility

4. A repetition statement specifies that an action is to be continued while some_______ remains true.

- a) Control

- b) Operator

- c) Condition

- d) Assignment

- Correct option: c) Condition

5. We can access a global variable ___________.

- a) From the main() function only

- b) From the loops only

- c) From the functions only

- d) From anywhere in the program

- Correct option: d) From anywhere in the program

6. The most suitable data type for number 325.25 is ______.

- a) int

- b) float

- c) double

- d) char

- Correct option: b) float


7. != operator is used to check whether the operand on the left-hand-side is ___________ to the
operand on the right-hand-side.

- a) Equal

- b) Greater than

- c) Less than

- d) Not equal

- Correct option: d) Not equal

8. Continue statement usually forces the immediate _____ iteration of the loop.

- a) Next

- b) Previous

- c) Final

- d) Last

- Correct option: a) Next

9. When the logical operator OR (||) combine two expressions exp1 and exp2 then the result will be
false only,

- a) When both exp1 and exp2 are false

- b) When both exp1 and exp2 are true

- c) When exp1 is true and exp2 is false

- d) When exp1 is false and exp2 is true

- Correct option: a) When both exp1 and exp2 are false

10. When the if statement consists of more than one statement then enclosing these statement in
braces is _________.

- a) Not required

- b) Compulsory

- c) Relevant

- d) Optional
- Correct option: b) Compulsory

1. < , <= , > , >= are called __________ operators.

- Arithmetic

- Relational

- Logical

- Conational

- Correct option: Relational

2. Loops are _______________ Structure.

- Sequential

- SequentialDecision

- None of the given options

- Correct option: SequentialDecision

3. X is an integer variable; what does X++ mean?

- None of these

- Add 1 in X value

- Add 2 in X value

- Add 1 two times in X value

- Correct option: Add 1 in X value

4. In call by reference, __________ of a variable is passed to the called function.

- Address

- Data type

- Value

- Name

- Correct option: Address


5. We use __________ to include all those functions in our program which are located in different files.

- Compiler

- Loader

- Debugger

- Linker

- Correct option: Linker

6. && is a ___________ operator.

- Logical

- Arithmetic

- Relational

- Mathematical

- Correct option: Logical

7. Comments are written to explain the ____________ of programs.

- Functionality

- Performance

- Reliability

- Consistency

- Correct option: Functionality

8. First step in designing a program is __________.

- Coding

- Linking

- Analysis

- Compiling

- Correct option: Analysis

9. A _____________ is a precise sequence of steps to solve a particular problem.


- Code Analysis

- Program

- Statement

- Algorithm

- Correct option: Algorithm

1. += , *= , /= , etc are called,

Options:

A) Assignment operators

B) Compound assignment operator

C) Unary operator

D) Logical operator

Correct Option: B) Compound assignment operator

2. Find out the logical error in the following lines of code.

```cpp

If (x = 10)

cout << “x is 10”;

```

Options:

A) Variable x should not be inside parenthesis

B) There is no semicolon at the end of if condition

C) Assignment operator should not be used for comparison

D) 10 should be enclosed in quotations

Correct Option: C) Assignment operator should not be used for comparison

3. What will be the result of the expression `j = i++;` if initially j = 0 and i = 5?

Options:

A) j will be 5
B) j will be 6

C) j will be 4

D) j will be 0

Correct Option: A) j will be 5

4. What will be the output of the following code segment?

```cpp

int value = 1;

switch (value+value){

case 1 :

cout << "Punjab " ;

break;

case 2 :

cout << "Lahore" ;

break;

default :

cout << "Pakistan" ; }

```

Options:

A) Punjab

B) Lahore

C) Pakistan

D) None of the above

Correct Option: B) Lahore

5. A variable declared within a code block becomes ________ variable for that block.

Options:

A) Static

B) Local
C) Integer

D) Global

Correct Option: B) Local

6. C++ is a ___________________ language.

Options:

A) Low level

B) High level

C) Machine

D) Assembly language

Correct Option: B) High level

7. What will be the output for the following code segment?

```cpp

for ( int num = 3; num <= 5; num++ )

if ( num % 2 != 0)

continue;

cout << num << " ";

```

Options:

A) 3 4 5

B) 4 5

C) 4

D) None of the above

Correct Option: C) 4

8. What will be the result of the expression `k = ++m;` if initially k = 0 and m = 5?


Options:

A) k will be 5

B) k will be 6

C) k will be 4

D) k will be 0

Correct Option: B) k will be 6

9. _________ statement is used to terminate the processing of a particular case and exit from switch
structure.

Options:

A) break

B) goto

C) if

D) continue

Correct Option: A) break

10. For breaking complex problems into smaller pieces we use _______.

Options:

A) Functions

B) Break statement

C) if/else

D) Loops

Correct Option: A) Functions

1. What is the output of the following code?

```cpp

for (int i = 5; i <= 5; i++) {

cout << i++;

cout << i;
}

```

Options:

A. 55

B. 56

C. 66

D. 57

Correct Option: C. 66

2. Which of the following is the correct operator to compare the values of two variables?

Options:

A. =

B. ==

C. :=

D. ===

Correct Option: B. ==

3. What will be the result of the arithmetic expression 6 + 48/4 * 3?

Options:

A. 20

B. 24

C. 36

D. 42

Correct Option: D. 42

4. ______ Loop executes at least one time.

Options:

A. Do-while

B. For
C. While

D. If

Correct Option: A. Do-while

5. What will be the output for the following code segment?

```cpp

for (int num = 3; num <= 5; num++) {

if (num % 2 != 0)

continue;

cout << num << " ";

```

Options:

A. 3

B. 4

C. 4 5

D. 5

Correct Option: B. 4

6. For the given function prototype, which of the given function calls is appropriate/correct.

Prototype: float add(int);

Options:

A. add(&x);

B. add(int x);

C. add(*x);

D. add(x);

Correct Option: D. add(x);

7. What will be the output of the following code segment?


```cpp

int value = 1;

switch (value+value){

case 1 :

cout << "Punjab " ;

break;

case 2 :

cout << "Lahore" ;

break;

default :

cout << "Pakistan" ;

```

Options:

A. Punjab

B. Lahore

C. LahorePakistan

D. Pakistan

Correct Option: B. Lahore

8. += , *= , /= , etc are called

Options:

A. Logical operator

B. Compound assignment operator

C. Unary operator

D. Assignment operators

Correct Option: B. Compound assignment operator

9. !( x > 3) means in C++ that


Options:

A. x is equal to 3

B. x is less than 3

C. x is greater than 3

D. x is less than or equal to 3

Correct Option: D. x is less than or equal to 3

10. In while loop, the condition is checked ______ the execution of loop.

Options:

A. During

B. After

C. Before

Correct Option: C. Before

1. If y = 20 and z = y++, then the value of z will be ____________.

A. 20 (Correct)

2. After evaluating the expression x = 10 + 3 * 4 / 2 – 1, the value of x will be ___________.

A. 11

B. 16 (Correct)

C. 15

D. 12

3. If (a > b && a > c), then the condition will be true __________.

A. a > b is true and a > c is false

B. Both a > b and a > c are true (Correct)

C. Both a > b and a > c are false

D. a > b is false and a > c is true


4. What is the output of the following code if the 3rd case is true:

```

switch (var)

case 'a':

cout<<"apple"<<endl;

case 'b':

cout<<"banana"<<endl;

case 'm':

cout<<"mango"<<endl;

default:

cout<<"any fruit"<<endl;

```

A. mangomango

B. any fruitnone of the aboveapple

C. Syntax Error

D. mangomango (Correct)

5. If x = 9; then the expression x %= 2; will calculate the value of x as __________.

A. 0

B. 2

C. 1 (Correct)

D. 4

6. Which of the following is a reserved word for data types in C/C++?

A. int (Correct)

B. string

C. void
D. class

7. What will be the output of the following program?

```

void car() {

cout << "Honda";

int main() {

Car();

```

A. Honda car

B. Syntax Error

C. Honda (Correct)

D. None of the given options

8. What will be the output of the following program?

```

void car() {

cout << "Honda";

int main() {

Car();

```

A. Honda car

B. Syntax Error (Correct)

C. Honda

D. None of the given options


9. Which of the following is the correct operator to compare the values of two variables?

A. =

B. == (Correct)

C. >

D. <

10. According to C++ norms, the first character of a variable name must be an alphabet or __________ .

A. Special character

B. None of the given options

C. Digit

D. Underscore (Correct)

1. What will be the output of the program if x = 10?

Options:

A. Condition 1 is true Condition 2 is true

B. Condition 1 is true Condition 2 is true

C. Both conditions are false

Correct Option: A

2. Which of the following is not the subcategory of the system software?

Options:

A. Utilities

B. Device drivers

C. Operating system

D. Application software

Correct Option: D

3. If int a = 50; then the value of a/= 3; will be,


Options:

A. 16

B. 17

C. 15

D. 18

Correct Option: A

4. Which of the following is the correct operator to compare the values of two variables?

Options:

A. =

B. *=

C. ===

Correct Option: C

5. Default mechanism of calling a function by passing it array is call by ________ and in case of passing
variable is call by ________.

Options:

A. Value, Value

B. Value, Reference

C. Reference, Reference

D. Reference, Value

Correct Option: B

6. When the logical operator AND (&&) combines two expressions exp1 and exp2 then the result will be
true only, _______________.

Options:

A. When exp1 is true and exp2 is false

B. When both exp1 and exp2 are true

C. When exp1 is false and exp2 is true


D. When both exp1 and exp2 are false

Correct Option: B

7. If x is declared as an integer, what will be the result of the given expression?

x=3*5%(2+2)/2

Options:

A. 1

B. 2

C. 3

D. 4

Correct Option: B

8. A variable of character data type occupies ________ byte(s) in memory.

Options:

A. One byte

B. Two bytes

C. Four bytes

D. Eight bytes

Correct Option: A

9. _______ Keyword is used to return some value from a function.

Options:

A. output

B. return

C. goto

D. break

Correct Option: B

10. Telling a computer what to do, is called ________.


Options:

A. Implementing

B. Designing

C. Programming

D. Compiling

Correct Option: C

1. After evaluating the expression x = 10 + 3 * 4 / 2 – 1, the value of x will be:

Options:

A) 15

B) 16

C) 17

D) 18

Correct option: B) 16

2. Which one of the following languages has been used to write the compiler of “C” language?

Options:

A) Fortran

B) C

C) Java

D) Basic

Correct option: B) C

3. The ________ is an unconditional branch of execution.

Options:

A) Continue statement

B) Goto statement

C) Default statement

D) Switch statement
Correct option: B) Goto statement

4. It is the job of ________ to transfer the executable code from hard disk to main memory.

Options:

A) Debugger

B) Loader

C) Linker

D) Interpreter

Correct option: B) Loader

5. Learning to program is important because it develops _______ and _______ abilities.

Options:

A) Analytical, Problem solving

B) Reading, Problem solving

C) Reading, Writing

D) Analytical, Writing

Correct option: A) Analytical, Problem solving

6. In C/C++, a variable’s name can start with the symbol ____________.

Options:

A) Underscore

B) Plus

C) Colon

D) Semicolon

Correct option: A) Underscore

7. How many times the following loop will execute?

```cpp

int j = 3;
while(j > 0)

cout << "Statements" << endl;

j -= 2;

```

Options:

A) 0

B) 1

C) 2

D) Infinite loop

Correct option: C) 2

8. If

```cpp

int a = 17;

int b = 3;

double c = a / b;

```

What will be value of variable c?

Options:

A) 5.0

B) 5

C) 6

D) 6.0

Correct option: A) 5.0

9. Which operator has the highest precedence?

Options:
A) (*, -, /, +)

B) + has the highest precedence

C) - has the highest precedence

D) * and / both have the same highest precedence

Correct option: A) (*, -, /, +)

10. ___________ are used to translate the code of our program into machine language.

Options:

A) Debuggers

B) Compilers

C) Linkers

D) Editors

Correct option: B) Compilers


🔥🔥 Paid Vu Lms Handling 🔥🔥
♦ 1 GDB= Rs 100
♦ 1 Quiz= Rs 200
♦ 1 Assignment=Rs 250

💎Agr complete handling krwatey hain 1 subject ki with all activities= Rs 500 (Half
Semester) 💎

LECTURES Play Service Available In Very Low Price. 🖥

🎊🎉80-100% Marks Guaranteed 🎉🎊

🔥 Miss Mehwish:03184148783🔥

You might also like