0% found this document useful (0 votes)
66 views

cs201 Midterm Solved Quiz 1 Fall 2014

This document contains the solutions to CS201 Quiz #1 provided by Masoom Fairy. The quiz contains multiple choice questions testing concepts from lectures 9-12 including arrays, functions, loops, and strings. Masoom Fairy provides the correct answer for each question along with references to the relevant lecture material.

Uploaded by

Danish Bashir
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views

cs201 Midterm Solved Quiz 1 Fall 2014

This document contains the solutions to CS201 Quiz #1 provided by Masoom Fairy. The quiz contains multiple choice questions testing concepts from lectures 9-12 including arrays, functions, loops, and strings. Masoom Fairy provides the correct answer for each question along with references to the relevant lecture material.

Uploaded by

Danish Bashir
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

CS201_Quiz #1 Solved with references by Masoom Fairy

What will be the size of following array? int arr[29];


Select correct option:

30 PAGE 105-106

29

28

If a function has not been declared before its definition, It is a

logical error

syntax error Lecture 9

run time error

None of these

When the break statement is encountered in a loop‟s body, it transfers the control
________from the current loop.

Inside

Outside By using break the loop will terminate.

To break statement

To continue statement

When we access a multidimensional array, each array index is surrounded by


________.

Single quotes ' '

Double quotes " "

Brackets [] Lecture 11

None of the given

char name [] = “Hello World” ; In the above statement, a memory of _______ characters
will be allocated

CS201_Quiz #1 Solved by Masoom Fairy


Page 1
CS201_Quiz #1 Solved with references by Masoom Fairy

13

11

12 Lecture 12

10

A variable declared within a code block becomes ______ variable for that block.

Static

Integer

Local Lecture 9

Global

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

Comma , Lecture 9

Semicolon ;

Colon:

Brackets()

The data type before a function name represents its,

Return Type Lecture 9

Switch support___

Integer

Character

Both integer and character Lecture 8

None

Characters of a string stored in an array can be accessed directly using array _______.

Manipulation

Superscript

CS201_Quiz #1 Solved by Masoom Fairy


Page 2
CS201_Quiz #1 Solved with references by Masoom Fairy

Subscript PAGE 123

Postscript

A variable declared within a code block becomes ______ variable for that block.

Static

Integer

Local Lec 9

Global

The data type before a function name represents its,

Return Type Lec 9

Function data

Function arguments

Function name

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

Comma , Repeated

Colon :

Semicolon ;

Double quotes "

From following; which one is the correct syntax of an array initialize: Array size is 10 and
it is of double data type to value 0?

arr[10] = {0.0};

double arr[10]= 0.0;

double arr[10] = {0.0}; Lec 12

double arr[] = 0.0;

In C/C++, by default arguments are passed by _____ to a function.

Value Lec 9

CS201_Quiz #1 Solved by Masoom Fairy


Page 3
CS201_Quiz #1 Solved with references by Masoom Fairy

Reference

Prototype

None of the given

By default, the starting index of an array in C++ is _____.

-1

0 Lec 11

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

Name

Data type

Value

Address PAGE 199

_ Keyword is used to return some value from a function.

Break Lec 9

Individual characters in a string stored in an array can be accessed directly using array

superscript

script

subscript PAGE 123

value

___________character is used to indicate the end of the string.

New line

Blank space

Null PAGE 144

CS201_Quiz #1 Solved by Masoom Fairy


Page 4
CS201_Quiz #1 Solved with references by Masoom Fairy

What will be the size of the array declared as int array[1000];


Select correct option:
999 Lec 11
1000
1001
1002

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

continue

break

goto

return Lec 9

From the following; which on is the correct syntax of an array declaration: array size is 5
and it is of float data type?
Select correct option:
float [5] name;
name[5] float;
float name[5];
None of the given options It will be float name[4];

What is the correct syntax to declare an array of 15 elements of type float?


Select correct option:
float array[15];
float[15] array;
float [15]array;
float array[14]; Lec 11

If a function has not been declared before its definition, It is a


Select correct option:
logical error
syntax error Lec 9
run time error
None of these

In C/C++, by default arguments are passed by _____ to a function.


Select correct option:
Reference
Value Lec 9

CS201_Quiz #1 Solved by Masoom Fairy


Page 5
CS201_Quiz #1 Solved with references by Masoom Fairy

Size
Data

From the following; which one is the range of Random number generator function
rand()?
Select correct option:
0 – 32768
1 – 32768
0 – 32767 Lec 10
1 – 32767

Null character is represented by _______ in C++.


Select correct option:
/0
\0 PAGE 113
\n
\t

What is the correct syntax to declare an array of 15 elements of type float?

float array[15];

float[15] array;

float [15]array;

None of these It will be float array[14];

What will be the output of following code segment?

for (int i = 2; i<10; i++)

if ( i == 5)

continue;

cout << i << "," ;

2,3,7,8,

CS201_Quiz #1 Solved by Masoom Fairy


Page 6
CS201_Quiz #1 Solved with references by Masoom Fairy

2,3,4,6,7,8,9

2,3,4

4,6,7,8,9

In C/C++; by default arguments are passed by _______ to a function.

Value Repeated

Reference

Type

Data

If a function has not been declared before its definition, It is a

logical error

syntax error Repeated

run time error

None of these

All elements of an array must be of_________ data type(s).

char and int

Same Lecture 11

Different

float and double

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

switch (var)

case „a‟:

cout<<”apple”<<endl;

CS201_Quiz #1 Solved by Masoom Fairy


Page 7
CS201_Quiz #1 Solved with references by Masoom Fairy

case „b‟:

cout<<”banana”<<endl;

case „m‟:

cout<<”mango”<<endl;

default:

cout<<”any fruit”<<endl;

apple

apple anyfruit

apple banana mango anyfruit

none of above There is no any break statement.

What will be the size of the following character array?

char name[] = “Adeel”;

7 Lec 12

_________statement is used to terminate the processing of a particular case and exit


from switch structure.

if

goto

break Lecture 8 (Repeated)

continue

CS201_Quiz #1 Solved by Masoom Fairy


Page 8
CS201_Quiz #1 Solved with references by Masoom Fairy

char name [] = “Hello World” ; In the above statement, a memory of _________


characters will be allocated

10

11

12 Lecture 12 (Repeated)

13

1- Return type of a function that does not return any value must be ________.

Char
Void Lecture 9
Int
void

2- Null character is used to indicate the __________ of string.

Start
End PAGE 114
Begin
middle

3- _________ will be used for enclosing function statements into a block.

""
()

{} Lecture 9

[]

4- 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;

CS201_Quiz #1 Solved by Masoom Fairy


Page 9
CS201_Quiz #1 Solved with references by Masoom Fairy

case „m‟:

cout”mango”endl;

default: cout”any fruit”endl;

• Apple
• apple anyfruit
• apple banana mango anyfruit
• none of above Repeated

5- When we access a multidimensional array, each array index is surrounded by


__________.

• Single quotes ' '


• Double quotes " "
• Brackets [] Lecture 11
• Commas , ,

6- If an array has 50 elements, what is allowable range of subscripts?

• 0 – 49 Lecture 11
• 1 – 49
• 0 – 50
• 1 – 50

7- What will be the size of the array declared as int array[1000];

• 999 Repeated
• 1000
• 1001
• 1002

8- All elements of an array must be of_________ data type(s).

• char and int


• Same Repeated
• Different

9- If we pass more than one arguments to a function then they are separated by
___________.

CS201_Quiz #1 Page Solved by Masoom Fairy


10
CS201_Quiz #1 Solved with references by Masoom Fairy

• Comma , Lecture 9 (Repeated)


• Colon :
• semicolon

10- To manipulate n-dimensional array ________ nested loops are required.

• n-2
• n-1
• n+1
•n

CS201_Quiz #1 Page Solved by Masoom Fairy


11

You might also like