Introduction to Programming

Introduction to Programming – CS201

Question No: 1 ( Marks: 1 ) – Please choose one

In order to get 256 from the number 2568 we divide this number by 10 and take,

► Its remainder

► The number

► Its quotient

Advertisement

► Its divisor

Question No: 2 ( Marks: 1 ) – Please choose one

The correct syntax of do-while loop is,

► (condition ) while; do { statements; };

► { statements; } do-while ();

► while(condition); do { statements; };

► do { statements; } while (condition);

 Question No: 3 ( Marks: 1 ) – Please choose one

Which of the following function(s) is/are included in stdlib.h header file?

► double atof(const char *nptr)

► int atoi(const char *nptr)

► char *strcpy ( char *s1, const char *s2)

► 1 and 2 only

 Question No: 4 ( Marks: 1 ) – Please choose one

If the break statement is missed in switch statement then,

► The compiler will give error

► This may cause a logical error

► No effect on program

► Program stops its execution

Question No: 5 ( Marks: 1 ) – Please choose one

The data type before a function name represents its,

► Return Type

► Function data

► Function arguments

► Function name

Question No: 6 ( Marks: 1 ) – Please choose one

Member function tellg() returns the current location of the _____________ pointer.

► tellptr()

► write()

► seekg()

► get()

Question No: 7 ( Marks: 1 ) – Please choose one

What does 5 | 6 , evaluate to in decimal where ‘|’ is bitwise OR operator?

►3

►4

►5

►7

Question No: 8 ( Marks: 1 ) – Please choose one

C is widely known as development language of _______ operating system.

► Linux

► Windows

► Unix

► Mac OS

Question No: 9 ( Marks: 1 ) – Please choose one

What will be

the result of arithmetic expression 6+27/3*3?

► 33

► 45

► 9

► 30

Question No: 10 ( Marks: 1 ) – Please choose one

How many

bytes are occupied by declaring following array of characters?

char str[] = “programming”;

► 10

► 11

► 12

► 13

Question No: 11 ( Marks: 1 ) – Please choose one

What will be

the correct syntax for initialization of pointer ptr with string “programming”?

► char ptr = ’programming’ ;

► char *ptr = “programming” ;

► char *ptr = ‘programming’ ;

► *ptr = “programming” ;

Question No: 12 ( Marks: 1 ) – Please choose one

What will be the result of expression x%= 2, if x = 7?

►x = 1

►x = 3

►x = 7

►x = 2

Question No: 13 ( Marks: 1 ) – Please choose one

UNIX has been developed in ________ language.

►JAVA

►B

►C

►FORTRAN

Question No: 14 ( Marks: 1 ) – Please choose one

Declaring structures does not mean that memory is allocated.

►True

►False

Question No: 15 ( Marks: 1 ) – Please choose one

What will be the value of i and j in the following code segment?

int i, j ;

int x[5] = {2, 3, 4, 8, 9} ;

int *ptr =&x[2];

i = (*ptr)++ ;

j = *ptr++ ;

►i = 5, j = 5

►i = 5, j = 8

►i = 4, j = 8

►i = 5, j = 9

Question No: 16 ( Marks: 1 ) – Please choose one

When an array element is passed to a function, it is passed by —————-.

► reference

► data type

► value

► data

Question No: 17 ( Marks: 1 ) – Please choose one

What is the output of the following statement?

int i = 2.5; do { cout i * 2; } while (i > 3 && i < 10);

(a) 510

(b) 5

(c) 48

(d) error

 Question No: 18 ( Marks: 1 ) – Please choose one

What does !(7) evaluate to in decimal where ! is a NOT operator?

(a) 7

(b) 8

(c) 9

(d) 10

 Question No: 19 ( Marks: 1 ) – Please choose one

The condition in while loop may contain logical expression but not relational expression.

(a) True

(b) False

 Question No: 20 ( Marks: 1 ) – Please choose one

Searching is easier when an array is already sorted

(a) True

(b) False

Question No: 21 ( Marks: 1 ) – Please choose one

If an array has 100 elements, what is allowable range of subscripts?

(a) 0 – 99

(b) 1 – 99

(c) 0 – 100

(d) 1 – 100

 Question No: 22 ( Marks: 1 ) – Please choose one

What will be the value of ‘a’ and ‘b’ after executing the following statements?

a = 3;

b = a++;

(a) 3, 4

(b) 4, 4

(c) 3, 3

(d) 4, 3

Question No: 23 ( Marks: 1 ) – Please choose one

What will be the correct syntax to initialize all elements of two-dimensional array to value 0?

(a) int arr[2][3] = {0,0} ;

(b) int arr[2][3] = {{0},{0}} ;

(c) int arr[2][3] = {0},{0} ;

(d) int arr[2][3] = {0} ;

 Question No: 24 ( Marks: 1 ) – Please choose one

Which of the following functionreturns the size of a string variable?

(a) strlength()

(b) stringlen()

(c) strlen()

(d) strLength()

 Question No: 25 ( Marks: 1 ) – Please choose one

What will be the range of numbers generated by function rand () % 9?

(a) 0 to 9

(b) 1 to 9

(c) 0 to 8

(d) 1 to 8

Question No: 26( Marks: 1 ) – Please choose one

Computer can understand only machine language code.

(c) True

(d) False

Question No: 26 ( Marks: 1 ) – Please choose one

What does 5 ^ 6 , evaluate to in decimal where ‘^’ is Exclusive OR operator?

(a) True

(b) False

Question No: 27 ( Marks: 1 ) – Please choose one

If the file is not properly closed in the program, the program ____________.

(a) Terminate normally

(b) Indicate Runtime error

(c) Indicate Compile time error

(d) Crashes

Question No: 28 ( Marks: 1 ) – Please choose one

Which of the following header file include string conversion functions?

(a) string.h

(b) stdlib.h

(c) ctype.h

(d) sconvert.h

Question No: 29 ( Marks: 1 ) – Please choose one

A precise sequence of steps to solve a problem is called

Ø Statement

Ø Program

Ø Utility

Ø Routine

Question No: 30 ( Marks: 1 ) – Please choose one

The Compiler of C language is written in

Ø Java Language

Ø UNIX

Ø FORTRON Language

Ø C Language

 Question No: 31 ( Marks: 1 ) – Please choose one

Initialization of variable at the time of definition is,

Ø Must

Ø Necessary

Ø Good Programming

Ø None of the given options

Question No: 32 ( Marks: 1 ) – Please choose one

In if structure the block of statements is executed only,

Ø When the condition is false

Ø When it contain arithmetic operators

Ø When it contain logical operators

Ø When the condition is true

 Question No: 33 ( Marks: 1 ) – Please choose one

Dealing with structures and functions passing by reference is the most economical method

Ø True

Ø False

Question No: 34 ( Marks: 1 ) – Please choose one

Pointer is a variable which store,

Ø Data

Ø Memory Address

Ø Data Type

Ø Values

Question No: 35 ( Marks: 1 ) – Please choose one

Preprocessor program perform its function before ______ phase takes place.

Ø Editing

Ø Linking

Ø Compiling

Ø Loading

Question No: 36 ( Marks: 1 ) – Please choose one

Which of the following can not be a variable name?

Ø area

Ø _area

Ø 10area

Ø area2

Question No: 37 ( Marks: 1 ) – Please choose one

Which looping process is best, when the number of iterations is known?

Ø for

Ø while

Ø do-while

Ø all looping processes require that the iterations be known

Question No: 38 ( Marks: 1 ) – Please choose one

Which character is inserted at the end of string to indicate the end of string?

Ø new line

Ø tab

Ø null

Ø carriage return

Question No: 39 ( Marks: 1 ) – Please choose one

Which of the following header file defines the rand() function?

Ø iostream.h

Ø conio.h

Ø stdlib.h

Ø stdio.h

Question No: 40 ( Marks: 1 ) – Please choose one

Commenting the code _____________________

Ø Makes a program easy to understand for others.

Ø Make programs heavy, i.e. more space is needed for executable.

Ø Makes it difficult to compile

Ø All of the given options.

Question No: 41 ( Marks: 1 ) – Please choose one

What’s wrong with this for loop?

for (int k = 2, k <=12, k++)

Ø the increment should always be ++k

Ø the variable must always be the letter i when using a for loop

Ø there should be a semicolon at the end of the statement

Ø the commas should be semicolons

Question No: 42 ( Marks: 1 ) – Please choose one

For which array, the size of the array should be one more than the number of elements in an array?

Ø int

Ø double

Ø float

Ø char

Question No: 43 ( Marks: 1 ) – Please choose one

All A template function must have at least ———- generic data type

► Zero

► One

► Two

► Three

Question No: 44 ( Marks: 1 ) – Please choose one

Which of the following statement is best regarding declaration of friend function?

► Friend function must be declared after public keyword

► Friend function must be declared after private keyword.

► Friend function must be declared at the top within class definition.

► It can be declared anywhere in class as these are not affected by the public and private keywords.

 Question No: 45 ( Marks: 1 ) – Please choose one

Which one of the following is the declaration of overloaded pre-increment operator implemented as

member function?

► Class-name operator +() ;

► Class-name operator +(int) ;

► Class-name operator ++() ;

► Class-name operator ++(int) ;

Question No: 46 ( Marks: 1 ) – Please choose one

Class is a user defined___________.

► data type

► memory referee

► value

► none of the given options.

Question No: 46 ( Marks: 1 ) – Please choose one

How many bytes will the pointer intPtr of type int move in the following statement? intPtr += 3 ;

► 3 bytes

► 6 bytes

► 12 bytes

► 24 bytes

Question No: 47 ( Marks: 1 ) – Please choose one

Which of the following is the correct C++ syntax to allocate space dynamically for an array of 10 int?

► new int(10) ;

new int[10] ;

► int new(10) ;

► int new[10];

Question No: 48 ( Marks: 1 ) – Please choose one

A Pointer is a special variable that contain

► Data values

► Memory Address

► Both data and values

► None of the given option

Question No: 49 ( Marks: 1 ) – Please choose one

Reference Value Type Data The code is written to __________ the program.

► implement

► design

► analysis

► none of the given options

Question No.50 (Marks:1) – Please choose one

Operator overloading can be performed through__________________.

Classes

► Function

Operators

Reference

Question No: 51 ( Marks: 1 ) – Please choose one

When a value is referred by a normal variable then it is known as,

► Direct Reference

Indirect Reference.

Partial Reference

Proper Reference

Question No: 52 ( Marks: 1 ) – Please choose one

Which of the following function is used to increase the size of already allocated memory chunk?

malloc

calloc

► realloc

free

Question No: 53 ( Marks: 1 ) – Please choose one

Which of the following is NOT a preprocessor directive?

#error

#define

#line

► #ndefine

 Question No: 54 ( Marks: 1 ) – Please choose one

The stream objects cin and cout are included in which header file?

► iostream.h

fstream.h

istream.h

ostream.h

Question No: 55 ( Marks: 1 ) – Please choose one

Overloaded delete operator function takes the same parameter as an argument returned by new operator

function.

► True

False

Question No: 56 ( Marks: 1 ) – Please choose one

When an array of object is created dynamically then there is no way to provide parameterized constructors

for array of objects.

► True

False

Question No: 57 ( Marks: 1 ) – Please choose one

C is widely known as development language of _______ operating system.

Linux

Windows

► Unix

Mac OS

Question No: 58 ( Marks: 1 ) – Please choose one

Computer can understand only machine language code.

► True

False

 Question No: 59 ( Marks: 1 ) – Please choose one

We can not define a function as a friend of a Template class.

True

► False

Question No: 60 ( Marks: 1 ) – Please choose one

What will be the value of ‘a’ and ‘b’ after executing the following statements?

A = 3;

b = a++;

3, 4

4, 4

3, 3

► 4, 3

 Question No: 61 ( Marks: 1 ) – Please choose one

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

Int addValue (int *a){

int b = (*a) + 2;

return b ;

}

main () {

int x =6 ;

cout << x << “,” ;

cout << addValue(&x) << “,” ;

cout << x ;

}

► 6,8,6

6,6,8

6,8,8

6,6,6

Question No: 62 ( Marks: 1 ) – Please choose one

_______ is used to trace the logic of the program and correct the logical errors.

Compiler

Editor

Linker

► Debugger

 Question No: 63 ( Marks: 1 ) – Please choose one

new and delete are _____ whereas malloc and free are _____.

Functions, operators

Classes, operators

► Operators, functions

Operators, classes

 Question No: 64 ( Marks: 1 ) – Please choose one

Like member functions, ______ can also access the private data members of a class.

Non-member functions

► Friend functions

Any function outside class

None of the given options

Question No: 65 ( Marks: 1 ) – Please choose one

Which situation would require the use of a non-member overloaded operator?

The overloaded operator is an Assignment operator.

► The left most operand is an object of a class.

The left operand is built-in data type.

The operator returns a reference.

Question No: 66 ( Marks: 1 ) – Please choose one

The stream insertion and stream extraction operators are already overloaded for ______.

User-defined data types

► Built-in data types

User-defined and built-in data types

None of the given options

Question No: 67 ( Marks: 1 ) – Please choose one

If we define an identifier with the statement #define PI 3.1415926 then during the execution of the program

the value of PI __________.

can not be replaced

None of the given options

► Remain constant.

► can be changed by some operation

Question No: 68 ( Marks: 1 ) – Please choose one

Assignment operator is ————————-associative.

► right

left

binary

unary

 Question No: 69 ( Marks: 1 ) – Please choose one

When ever dynamic memory allocation is made in C/C++, it is freed_____________.

► Explicitly

► Implicitly

Both explicitly and implicitly

None of the given options

Question No: 70 ( Marks: 1 ) – Please choose one

The appropriate data type to store the number of rows and colums of the matrix is____________.

float

► int

char

none of the given options.

Question No: 71 ( Marks: 1 ) – Please choose one

Which of the following function do NOT initialize the chunk of memory to all zero?

calloc() function

Both malloc() and calloc()

None of the above

► malloc() function

Question No: 72 ( Marks: 1 ) – Please choose one

The function free() returns back the allocated memory got thorough calloc and

malloc to _____ .

stack

► heap

stack and heap

None of the given options

Question No: 73 ( Marks: 1 ) – Please choose one

width() is member function of _____________

cin object

cout object

► Both cin and cout object

None of the given option

Question No: 74 ( Marks: 1 ) – Please choose one

Templates are not type safe.

► true

► false

Question No: 75 ( Marks: 1 ) – Please choose one

A Matrix can be composed of ints, floats or doubles as their elements. Best way is to handle this ,

_______________

Write a separate class to handle each

► Use templates

Use strings to store all types

None of the given options

 Question No: 76 ( Marks: 1 ) – Please choose one

In if structure the block of statements is executed only,

When the condition is false

When it contain arithmetic operators

When it contain logical operators

► When the condition is true

 Question No: 77 ( Marks: 1 ) – Please choose one

Header file: fstream.h includes the definition of the stream classes __________.

ifstream, fstream, cout

► ifstream, fstream, ofstream

fstream, cin, cout

None of the above

Question No: 78 ( Marks: 1 ) – Please choose one

To access the data members of structure _______ is used.

► dot operator (.)

* operator

U operator

None of given.

Question No: 79 ( Marks: 1 ) – Please choose one

eof( ), bad( ), good( ), clear( ) all are manipulators.

► True

False

 Question No: 80 ( Marks: 1 ) – Please choose one

Which kind of functions can access private member variables of a class?

► Friend functions of the class

Private member functions of the class

Public member functions of the class

Friend, private and public functions

Question No: 81 ( Marks: 1 ) – Please choose one

The return type of operator function must always be void.

True

► False

 Question No: 82 ( Marks: 1 ) – Please choose one

Friend function of a class is ______________ .

Member function

► Non-member function

Private function

Public function

Question No: 83 ( Marks: 1 ) – Please choose one

Function implementation of friend function must be defined outside the class.

True

► False

 Question No: 84 ( Marks: 1 ) – Please choose one

The normal source of cin object is,

File

Disk

► Keyboard

RAM

Question No: 85 ( Marks: 1 ) – Please choose one

Which of the following is correct way to initialize a variable x of int type with value 10?

int x ; x = 10;

► int x = 10;

int x, x = 10;

x = 10;

Question No: 86 ( Marks: 1 ) – Please choose one

Consider the following code segment. What will be the output of the following program?

int func(int) ;

int num = 10 ;

int main(){

int num ;

num = 5 ;

cout << num ;

cout << func(num) ;

}

int func(int x){

return num ;

}

► 5, 5

10, 5

► 5, 10

10, 10

Question No: 87 ( Marks: 1 ) – Please choose one

With template function, the compiler automatically detects the passed data and generates a new copy of

function using passed data.

► True

False

Question No: 88 ( Marks: 1 ) – Please choose one

What will be the correct syntax to declare two-dimensional array of float data type?

float arr{2}{2} ;

► float arr[2][2] ;

float arr[2,2] ;

float[2][2] arr ;

Question No: 89 ( Marks: 1 ) – Please choose one

The first parameter of operator function for << operator,

Must be passed by value

► Must be passed by reference

Can be passed by value or reference

Must be object of class

Question No: 90 ( Marks: 1 ) – Please choose one

Heap is constantly changing in size.

► True

False

Question No: 91 ( Marks: 1 ) – Please choose one

While calling function, the arguments are assigned to the parameters from _____________.

► left to right.

right to left

no specific order is followed

none of the given options.

Question No: 92 ( Marks: 1 ) – Please choose one

Classes defined inside other classes are called ________ classes

looped

► nested

overloaded

none of the given options.

Question No: 93 ( Marks: 1 ) – Please choose one

If we define an identifier with the statement #define PI 3.1415926 then during the execution of the program

the value of PI __________.

can not be replaced

None of the given options

► Remain constant.

can be changed by some operation

Question No: 94 ( Marks: 1 ) – Please choose one

Which value is returned by the destructor of a class?

A pointer to the class.

An object of the class.

A status code determining whether the class was destructed correctly

► Destructors do not return a value.

 Question No: 95 ( Marks: 1 ) – Please choose one

Every class contains _______________.

Constructor

Destructor

► Both a constructor and a destructor

None of the given options

Question No: 96 ( Marks: 1 ) – Please choose one

A template function must have

► One or more than one arguments

Only one argument

Zero arguments

None of the given options

 Question No: 97 ( Marks: 1 ) – Please choose one

Structured Query Language is used for ______________

► Databases Management

Networks

Writing Operating System

none of the given options

Question No: 98 ( Marks: 1 ) – Please choose one

When a call to a user-defined function finishes, the variable defined inside the function is still in existence.

True

► False

 Question No: 99 ( Marks: 1 ) – Please choose one

The precedence of an operator can be changed through operator overloading.

True

► False

Question No: 100 ( Marks: 1 ) – Please choose one

A Matrix can be composed of ints, floats or doubles as their elements. Best way is to handle this ,

_______________

Write a separate class to handle each

► Use templates

Use strings to store all types

None of the given options