Home Tuitions

CUET CS Chapter-C++ Revision Tour 

Board CBSE
Textbook NCERT
Class Class 12
Subject Computer Science
Chapter CUET CS Chapter-C++ Revision Tour 
Chapter Name C++ Revision Tour
Category CUET (Common University Entrance Test) UG

MCQ-Based Questions for CUET Computer Science Chapter-C++ Revision Tour 

This page is prepared by HT experts and consists of MCQ-Based Questions for the CUET Computer Science chapter-C++ Revision Tour with a detailed explanation of all the questions asked from C++ Revision Tour. To find the solution to the MCQ questions click on the answer tab. Check out chapter-wise CUET computer science Practice MCQ Based Questions. 

Practice Questions for CUET Computer Science chapter-C++ Revision Tour SET-1

Computer Science - MCQ on C++ Revision Tour

Class XII

Q.1 C++ is a general purpose programming language. It is also called as

a) high level language.

b) low level language.

c) middle level language.

d) assembly language.

Answer:

(c)

Explanation: C++ is a middle level language. It has features of a high level language and low level language.

Q.2 Procedural language paradigm gives more emphasis on

a) data than the work performed on it.

b) doing things rather than on data itself.

c) objects and classes.

d) principles of data hiding, abstraction and encapsulation.

Answer:

(b)

Explanation: Procedural programming aims at procedures. It is a list of instructions telling a computer, step by step, what to do, usually having a linear order of execution from the first statement to the second.

Q.3 Hiding intricate details from the end user

a) is not an essential principal of system design.

b) is a conventional programming approach.

c) is same as data abstraction.

d) is a way to implement data abstraction.

Answer:

(d)

Explanation: Encapsulation is wrapping up of data and functions into a single unit and it is a way to implement polymorphism.

Q.4 Smallest individual unit in a program is called

a) token/lexical unit.

b) keyword.

c) identifier.

d) functions.

Answer:

(a)

Explanation: A token is the smallest element of a C++ program that is meaningful to the compiler. It includes keywords, identifiers and literals.

Q.5 Keywords are also called as

a) literals.

b) reserved words.

c) separators.

d) punctuators.

Answer:

(b)

Explanation: Keywords are also called as reserved words. Punctuators are {},[],; * etc.

Q.6 During a program run, literals are

a) constants.

b) varying float numbers.

c) varying integers.

d) string.

Answer:

(a)

Explanation: Literals are data items that never change their value during a program run. They are integer constant, character-constant, floating constant and string –literal.

Q.7 A string literal refers to

a) multiple character surrounded by single quotes.

b) multiple characters surrounded by double quotes.

c) strings where terminating character ‘ \0’ is not added.

d) character constants.

Answer:

(b)

Explanation: A string literal is a sequence of characters surrounded by double quotes.

Q.8 Fundamental data types in c++ are

a) same as derived data types.

b) arrays, functions and pointers.

c) float, int, void.

d) unions and enumerations.

Answer:

(c)

Explanation: There are 5 fundamental data types in c++: char, int, float, double and void.

Q.9 main () which has the program code to be executed is a

a) class.

b) sub class.

c) object.

d) function name.

Answer:

(d)

Explanation: Every c++ program has a function main ().

Q.10 All statements in C++ terminate with

a) double quotes.

b) semicolon.

c) colon.

d) single quotes.

Answer:

(b)

Explanation: Every statement in c++ terminates with a semicolon (;)

Q.11 Unary operator in used in c++ programs require

a) two operands.

b) no operand.

c) one operand.

d) any no of operands.

Answer:

(c)

Explanation: C++ provides two unary arithmetic operators-unary plus and unary minus. Unary operators operate on only one operand, which could be a constant or a variable.

Q.12 The assignment operator used in c++ programs

a) assigns the l value to the r value (left to right rule).

b) assigns the r value to the l value (right to left rule).

c) can be in either way.

d) compare two values.

Answer:

(b)

Explanation: The assignment operation always takes place from right to left, and never the other way. Example: a=b; this statement assigns to variable a (the l value) the value contained in variable b (the r value).

Q.13 # are directives for the

a) compiler.

b) editors.

c) interpreter.

d) preprocessor

Answer:

(d)

Explanation: # are preprocessor directives.

Q.14 At the lowest level files are treated as a stream of

a) arrays.

b) bytes .

c) octal numbers.

d) hexadecimal numbers.

Answer:

(b)

Explanation: Files are treated as a stream of bytes at the lowest level.

Q.15 Programs always begin with function

a) enter ().

b) output ().

c) start ().

d) main ().

Answer:

(d)

Explanation: Programs always begin with function main ()

Q.16 Fundamental data types are of

a) 2 types.

b) 4 types.

c) 5 types.

d) 3 types.

Answer:

(c)

Explanation: There are 5 fundamental data types in c++: char, int, float, double and void.

Q.17 Multiple character have data type

a) int.

b) char.

c) float.

d) double.

Answer:

(a)

Explanation: A character data is always declared with the char data type.

Q.18 To assign bit wise XOR, symbol is

a) ||=

b) ^=

c) && =

d) &=

Answer:

(b)

Explanation: To assign bit wise XOR, symbol is ^=

Q.19 The invalid identifier is

a) _abc

b) age16

c) 35students

d) $rules

Answer:

(c)

Explanation: Identifier 35students is invalid as it starts with a number. An identifier is a sequence of characters. _ and $ are legal identifiers in c++ but 0,1,2 are not.

Q.20 A number of functions can be grouped and kept as a separate entity called

a) module.

b) abstraction.

c) polymorphism.

d) data.

Answer:

(a)

Explanation: A group of functions together forms a larger identity called module

Q.21 Properties are inherited by

a) base class.

b) class.

c) derived class.

d) super class.

Answer:

(c)

Explanation: The derived class inherits properties of a base class.

Q.22 Values can be input to variables in the program using the stream

a) cin.

b) cout.

c) input.

d) output.

Answer:

(a)

Explanation: cin correspond to the standard input stream, which represents data coming from the keyboard.

Q.22 Values can be output to variables in the program using the stream

a) cin.

b) cout.

c) input.

d) output.

Answer:

(b)

Explanation: Identifier cout corresponds to the output stream, which represents data being displayed to the output screen.

Q.23 Comments in c++ start with

a) //

b) {

c) ;

d) *

Answer:

(a)

Explanation: C++ supports two types of comments: // for single line comments and /* */ style for commenting out a block of code.

Q.24 The looping process which checks the test condition at the end of the loop is

a) for loop.

b) while loop

c) do while loop

d) no looping process checks the condition at the end.

Answer:

c)

Explanation: In the do while loop, code is executed at least once even if the condition is false.In this loop the condition is evaluated at the end.

Q.25 The statement i++; is equivalent to

a) i=i+1.

b) i=i-1.

c) i=i+i.

d) i=i+0.

Answer:

(a)

Explanation: i++ is equal to i+1. ++ is an increment operator which increments value by 1.

Q.26 The statement i--; is equivalent to

a) i=i+1.

b) i=i-1.

c) i=i+i.

d) i=i+0.

Answer:

(b)

Explanation: i-- is equal to i-1. --is a decrement operator which decrements value by 1. for example a—is equal to a-1.

Q.27 If there is more then one statement in the block of a for loop, the bracket which is placed at the beginning and the ending of the loop block is

a) Parenthesis ()

b) Braces {}

c) Brackets []

d) Arrows <>

Answer:

(b)

Explanation: {} are used for more than one statement in the block of a for loop. When there is a single statement then () are used. Example: for (I=0;I<10;I++). It will execute the code within for loop 10 times.

Q.28 A continue statement causes execution to skip to

a) the return 0; statement.

b) the first statement after the loop.

c) the statement following the continue statement.

d) the next iteration of the loop.

Answer:

(d)

Explanation: Continue statement ends the current iteration of a loop. Program control is passed from the continue statement to the end of the loop body.

Q.29 Error in the following code is

while (i<10 && (i>24

a) the logical operator && cannot be used with while statement.

b) the while loop is an exit condition loop.

c) the test condition is always false.

d) the test condition is always true.

Answer:

(c)

Explanation: Here the condition is always false. It will never be true.

Q.30 Error in the code below is

for (k=0, k<10, k++)

a) the commas should be semicolon.

b) there should be a semicolon at the end of the statement.

c) there is no error.

d) the increment should always be ++k.

Answer:

(a)

Explanation: In the for loop the proper syntax is for (initialization; condition; increment). So it should be for (k=0; k<10; k++).

Q.31 The correct statement according to the code below is

Struct aditi {

union {

int i;

char ch[2];

} ;

};

a) this would give an error as no union name defined.

b) nesting union within struct is not allowed.

c) this is correct and legal in C++.

d) this is correct and legal in c and c++.

Answer:

(c)

Explanation: This is legal in c++ but not in c. Unions, which do not have a class name, they are anonymous union.

Q.31 The correct statement according to the code below is

void *a;

char *b;

a=b;

b=a;

a) this is correct.

b) it would give an error as ‘a’ cannot be assigned to ‘b’.

c) it would give an error as ‘b’ cannot be assigned to ‘a’.

d) error in statement 3 and 4.

Answer:

(b)

Explanation: In c++, void pointer cannot be assigned to the pointer of any type. This would give an error of type mismatch. It can be made true when we explicitly typecast it, b=(char*) a;

Q.32 The program design method we learned in order to write object-oriented programs is

a) declare-define-use.

b) public functions and private variables.

c) top down programming.

d) bottom up programming.

Answer:

(b)

Explanation: Object oriented systems use bottom up approach. It uses concept of objects and classes.

Q.33 To implement the relationship in c++ we use

a) polymorphism.

b) inheritance.

c) overloading.

d) overriding.

Answer:

(b)

Explanation: The property by which one class (subclass) inherits the properties of super class is known as inheritance. This is a relationship between subclass (derived class) and superclass (base class).

Q.34 An abstract class is such that it can have

a) one instance.

b) one or two instances.

c) multiple instances.

d) zero instances.

Answer:

d) Abstract classes cannot be instantiated.Abstract classes are classes that contain one or more abstract methods. An abstractmethod is a method that is declared, but contains no implementation.

Q.35 The programming technique, which focuses on the algorithm, is

a) procedural language.

b) object oriented language.

c) object based language.

d) structural language.

Answer:

(a)

Explanation: Procedural languages are used in the traditional programming that is based on the algorithms.

Q.36 The essential characteristics of an object, which distinguish it from all other kinds of objects, is

a) aggregation.

b) abstraction.

c) modularity.

d) encapsulation.

Answer:

(b)

Explanation: Abstraction is focusing on the details of an object leaving behind the implementation details.

Q.37 The good example of a method that is shared by all instance of a class is

a) constructor.

b) attribute.

c) constructor and attribute.

d) overloading.

Answer:

a)

Explanation: A constructor is a special member function, which will construct an object with user-defined values whenever object is created. It is a special method used in oops which puts the object member into a valid state.

Q.38 An abstract class is the class that

a) does not have method definitions.

b) has a constructor which takes no arguments.

c) must have a function definition equal to zero.

d) can only exist during the planning phase.

Answer:

(a)

Explanation: Abstract classes are classes, which cannot be instantiated but they can have sub classes. They do not have method definitions but the prototypes and declarations can be done.

Q.39 The ability to reuse objects already defined, perhaps for a different purpose, with modification appropriate to the new purpose, is referred to as

a) information hiding.

b) inheritance.

c) redefinition.

d) overloading.

Answer:

(d)

Explanation: A type of polymorphism where different functions with the same name are invoked based on the data types of the parameters passed is called overloading.

Q.40 When a class uses dynamic memory, the member function invoked by the class is

a) an overloaded assignment operator.

b) a destructor.

c) a copy constructor.

d) no member functions provided.

Answer:

(b)

Explanation: In dynamic memory allocation whenever the object is out of scope, its memory would be freed and deallocated. So a destructor is automatically invoked by the class.

Q.41 A variable used in c++ can be tied with

a) zero reference.

b) only one reference.

c) two references.

d) several references.

Answer:

(d)

Explanation :We can create two or more references for the same variable but same reference can not be tied with several variables.

Q.42 A recursive function would result in infinite recursion, if the following were left out

a) base case.

b) recursive call.

c) subtraction.

d) local variable declarations.

Answer:

(a)

Explanation: A base case is the initial condition given when we write any recursive function. For example in a program which finds out the factorial of a number the base case is n=0 or n=1,without which it will result in infinite recursion.

Q.43 If the test class does not have an overloaded assignment operator, when an assignment a=b; is given for two test objects a and b, then

a) the automatic assignment operator is used.

b) the copy constructor is used.

c) compiler error.

d) run-time error.

Answer:

(b)

Explanation: Copy constructor will copy the value of b into test object a.

Q.44 Interface is also known as

a) virtual class.

b) dependent class.

c) pure abstract class.

d) class.

Answer:

(c)

Explanation: Interface generally refers to an abstraction that an entity provides of itself to the outside. This separates the methods of external communication from internal operation, and allows it to be internally modified without affecting the way outside entities interact with it, as well as provide multiple abstractions of itself.

Q.45 The header file in which clrscr() function is present is

a) conio.h.

b) stdio.h.

c) iostream.h.

d) iomanip.h.

Answer:

(a)

Explanation: clrscr() is a console input output function.

Q.46 Every function in c++ has its code

a) within square brackets.

b) within angular bracket.

c) within curly braces.

d) no bracket used etc .

Answer:

(b)

Explanation : Every function in c++ has its code within curly braces. {}

Q.47 << and >> are called

a) cascading stream.

b) stream.

c) cascading stream of input and output operators.

d) keywords.

Answer:

(c)

Explanation: << is called insertion or put to operator. It directs the contents of the variable on its right to the object on its left. >> is extraction operator. Together these are called as cascading stream of input and output operators.

Q.48 The error in this statement cout<<computers can be fun ;

a) >> should be used instead of <<.

b) double quotes are not used.

c) there should be a space between < and <.

d) semicolon should not be used.

Answer:

(b)

Explanation: Correct sentence is cout<<”computers can b fun”’;

Q.49 Data type identifies

a) type of data only.

b) type of data & its associated operations for handling it.

c) operations for handling data only.

d) data, operations and memory allocations.

Answer:

(b)

Explanation: A data type is a class which defines the class members, their properties and the operations which can be performed on the members. Example int is a class of integers defining arithmetic operations on members.

Q.50 A class in c++ is known as empty class if it

a) has more than a name.

b) has no member functions.

c) is just a name.

d) has no common properties.

Answer:

(c)

Explanation: A empty class has no variable declarations, no functions or methods but the objects of these classes can have non–zero size.

Practice Questions for CUET Computer Science chapter-C++ Revision Tour SET-2

Q.51 ‘\n’ which is used in c++ is an

a) escape sequence for start.

b) escape sequence for end.

c) escape sequence for null.

d) escape sequence for new line.

Answer:

(d)

Explanation: \’n’ is an escape sequence for new line. It sends the new line character but does not flush the output buffer.

Q.52 The function of endl is

a) same as ‘\n’.

b) sends a newline character ‘\n’ and flushes the output buffer.

c) only flushes the output buffer.

d) sends a newline character ‘\n’ but does not flushes the output buffer.

Answer:

(b)

Explanation: Both ‘\n’ and endl manipulator sends a new line character ‘\n’ but endl also flushes the output buffer whereas ‘\n’ does not flushes the output buffer.

Q.53 Manipulators used in c++ are

a) setw, setiosflags, setfill, setprecision.

b) cout, cin.

c) ‘\n’.

d) setw, endl and scope resolution operator.

Answer:

(a)

Explanation: setw, setiosflags, setfill, setprecision, endl are manipulators.

Manipulators are used to change formatting parameters on streams and to insert or extract certain special characters.

Q.54 C++ was developed by

a) Bjarne Stroustrup.

b) Dennis Ritchie.

c) Rick Mascitti.

d) Brian Kernighan.

Answer:

(a)

Explanation: C++ was developed by Bjarne Stroustrup at AT & T Bell Laboratories in early 1980. He called it ‘C with Classes’. The name c++ was coined by Rick Mascitti.

Q.55 Implicit conversion in c++ is performed by

a) programmer.

b) compiler.

c) preprocessor.

d) interpreter.

Answer:

(b)

Explanation: There are 2 types of conversions available in c++ : implicit and explicit conversions. Implicit conversions are performed by compilers in those expressions which have mixed data types.

Q.56 Result of conditional operator? exp1:exp2 is

a) exp1

b) exp2

c) can be either exp1 or exp2

d) both exp1 and exp2.

Answer:

(a)

Explanation: When condition is true, it will always give result as exp1, whereas when condition is false then it will give result as exp2.

Q.57 Program element ‘OxFE’ is an

a) integer.

b) character constant.

c) hexadecimal integer constant.

d) integer constant.

Answer:

(d)

Explanation: Invariant program elements are called "literals" or "constants." The terms "literal" and "constant" are used interchangeably here. OxFE is an integer constant.

Q.58 The invalid form of real constant is

a) –0.00625

b) 35.66

c) + 5.0

d) 15,356.30

Answer:

(d)

Explanation: The form of a real constant is basic real constant, basic real constant followed by a real exponent, integer constant followed by a real exponent. A real exponent is the letter E followed by an optionally signed integer constant. Basic real constant is an optional sign, an integer part, a decimal point and a fractional part.

Q.59 Floating constants are

a) integer constant.

b) real constants.

c) char constant.

d) does not exists.

Answer:

(b)

Explanation: A floating constant has a value part that may be followed by an exponent part and a suffix specifying its type.

Q.60 A character constant is

a) enclosed in double quotes .

b) enclosed in single quotes.

c) enclosed in brackets.

d) enclosed in parenthesis.

Answer:

(b)

Explanation: Text enclosed in single quotes is treated as character constant. The type of character constant is int. Its value is the ASCII code for the character.

Q.61 sizeof() operator used in c++ programs accept

a) one parameter only.

b) two parameters only.

c) one or more parameters.

d) multiple parameters.

Answer:

(a)

Explanation: sizeof() operator accepts one parameter, which can be either a type or a variable itself and return the size in bytes of that type or object.

Q.62 Keywords as normal identifier names

a) can not be used.

b) can be used.

c) may/may not be used.

d) can only be used.

Answer:

(b)

Explanation: Keywords are reserved words. They cannot be used as identifier names. It is illegal in c++.

Q.63 The properties of ‘characters’ used in c++ are that they are

a) implement dependent.

b) not implement dependent.

c) array independent.

d) structures dependent.

Answer:

(a)

Explanation: Characters are implement dependent. A character represents any letter, digit, special symbols and white spaces.

Q.64 The statement which is valid or legal in c++ is

a) A reference can be used without proper initialization.

b) Array of references is legal in c++.

c) Char, int pointers can refer to null pointers but null pointers cannot refer to other pointers.

d) Array of pointers is not legal in c++.

Answer:

(c)

Explanation: A reference has to be properly initialized, otherwise it will result in an error. In c++ special care is taken for assignment of void pointers to other pointer types. While we can assign a pointer of any type to a void pointer the reverse is not true until we do explicit typecasting.

Q.65 The statement which is valid or legal in c++ is

a) An identifier can start with the “_”.

b) An identifier can begin with a digit.

c) All special characters are allowed in c++ identifiers.

d) Single character constants have type char.

Answer:

(a)

Explanation: Identifiers can start with _, but not digits. Identifier is an arbitrarily long sequence of letters and digits. Upper and lower case are different. Single character constants have type int.

Q.66 The identifier which is not legal is

a) Myfile

b) _chk

c) break

d) _hj_as

Answer:

(c)

Explanation: Special characters, keywords and first character, as digit is not acceptable as identifier in c++.

Q.67 The invalid real constant is

a) 2.0

b) 17.5

c) 72,340.42

d) -0.00987

Answer:

(c)

Explanation: Real constants are numbers having fractional parts. These may be written in fractional form or exponent form. It must have at least one digit before decimal and one digit after decimal and commas are not allowed.

Q.68 The invalid real constant is

a) 152E05

b) 1.52E07

c) 152E+8

d) 172.E5

Answer:

(d)

Explanation: A real constant in exponent form has two parts: a mantissa and an exponent. The mantissa must be either an integer or a proper real constant. The mantissa is followed by a letter E or e and the exponent. The exponent must be an integer.

Q.69 Operators (==, <=, >= ) used in c++ programs are called as

a) logical operators.

b) relational operators.

c) conditional operators.

d) arithmetic operators.

Answer:

(b)

Explanation: Logical operators are (&&,||,!) , arithmetic operators are (+,-,*,/,%),and conditional operator is (? :).

Q.70 The run-time error is

a) file could not be opened.

b) MAX+2=DMAX

c) missing of semicolon at the end of code.

d) error when statements are wrongly written violating rules of a program.

Answer:

(a)

Explanation: Run time error is an error that occurs during execution of a program. The compilation is not affected by it.

Q.71 Assuming that res starts with the value 25, the result of the following code fragment is

cout<<res--;

cout>>++res;

a) 25 26

b) 25 24

c) 24 25

d) 24 26

Answer:

(a)

Explanation: res-- is using post decrement operator. First it will print the value and then the value will decrease by 1. ++res is using pre increment operator, this will first increment the value and then print the result.

Q.72 The result of following expression

ans-( val<500?150:50 when ans=800 val=700, is

a) 700.

b) 750.

c) 150.

d) 650.

Answer:

(b)

Explanation: According to the precedence of operators first bracket will be evaluated.

Q.73 Error in the code below is

main()

{

int i=j=k=0;

}

a) multiple assignment statement requires pre declaration of variables.

b) multiple assignment is not possible.

c) initialization should be outside the braces.

d) every variable should be declared independently.

Answer:

(a)

Explanation: j and k are not being declared before using assignment operation. Correct way is int i, j ,k; to be used before assignment.

Q.74 Error in the code below is

main()

{

int i, j;

int *ip;

i=j=ip=0;

}

a) pointer cannot be used in assignment statement.

b) ip is a pointer and cannot be used as integer.

c) pointer should not be initialized.

d) pointer can not be equal to zero.

Answer:

(b)

Explanation: A pointer points to the address of a variable. It cannot be used as integers.

Q.75 Evaluate a+=a++ + ++a, when a=20 initially

a) 64.

b) 61.

c) 42.

d) 41.

Answer:

(a)

Explanation: The post increment operator first prints the value and then increment whereas the pre increment operator first increments the value then print.

Q.76 The correct statement is

a) function getline() can read white spaces( spaces, tabs etc.).

b) function getline() and gets() are same functions.

c) getline(), putline(),get() and put() functions are defined in stdio.h.

d) gets() and puts() are defined in iostream.h.

Answer:

(a)

Explanation: getline(), putline(),get() and put() functions are unformatted stream in functions in header file iostream.h whereas gets() and puts() are string functions in stdio.h.

Q.77 Vectors in c++ consists of

a) integers.

b) floating point numbers.

c) integers and floating point numbers.

d) characters.

Answer:

(c)

Explanation: Vectors in c++ consists of only integers and floating point numbers.

Q.78 The header file, which declares various functions used in calling Dos console I/O routines, is

a) conio.h

b) iostream.h

c) stdio.h

d) string.h

Answer:

(a)

Explanation: conio.h is console input output header file. These have libraries of code which we may insert in the program, by using as a reference in the top block.

Q.79 The header file, which defines types and macros needed for the standard I/O package, is

a) conio.h

b) iostream.h

c) stdio.h

d) string.h

Answer:

(c)

Explanation: stdio.h is standard input output header file. These have libraries of code which we may insert in the program, by using as a reference in the top block.

Q.80 The header file, which declares basic c++ stream I/O routines, is.

a) conio.h

b) iostream.h

c) stdio.h

d) iomanip.h

Answer:

(b)

Explanation: iostream.h contains 2 files : istream and ostream. These have libraries of code which we may insert in the program, by using as a reference in the top block.

Q.81 The correct output of the following program is

#include<iostream.h>

void main()

{

int i=5;

int &j=i;

int p=10;

j=p;

cout<<endl<<i<<endl<<j;

p=20;

cout<<endl<<i<<endl<<j;

}

a) 10 10 10 10.

b) 10 5 20 20.

c) 5 10 10 10.

d) 10 10 20 20.

Answer:

(a)

Explanation: j is a reference to i. If, we assign value of p to j, then value of i also changes.

Q.82 The correct output of the following program is

#include<iostream.h>

void main()

{

char *p=”abc”;

char *q=p;

cout<<p<<endl<<q ;

q=”xyz”;

cout<<p<<endl<<q ;

}

a) abc xyz abc xyz.

b) abc abc abc xyz.

c) abc abc xyz xyz.

d) abc abc abc abc.

Answer:

(b)

Explanation: value of p is assigned to pointer q . So initially *p and * q will have same value.

Q.83 The correct output of the following program is

#include<iosteam.h>

int i=20;

void main()

{

int i=5;

cout<<i <<endl<<::i ;

}

a) 5.

b) 20 20.

c) 5 20.

d) 20 5.

Answer:

(c)

Explanation: :: is a scope resolution operator, which takes the global value of i.

Q.84 The correct output of the following program is

#include<iostream.h>

int i=25;

void main()

{

int i=5;

cout<<i <<endl<<::i ;

{

int i=10;

cout<<i <<endl<<::i ;

}

}

a) 5 5 25.

b) 5 25 10 5.

c) 5 25 5 25.

d) 5 25 10 25.

Answer:

(d)

Explanation: :: is a scope resolution operator, which takes the global value of i.

Q.85 The correct output of the below code is

#include<iostream.h>

void main()

{

int I=5;

if (I=2

{cout<<”hello”;

}

else

cout<<”this is end”;

}

a) print hello one time.

b) print this is end.

c) compiler error.

d) run time error.

Answer:

(a)

Explanation: It will always print hello because we have used assignment operator here instead of comparison operator.

Q.86 The correct output of the following program is

#include<iostream.h>

void main()

{

int i ;

cout<<sizeof (i) <<endl<< sizeof (‘i’);

}

a) 2 1.

b) 2 2.

c) 1 1.

d) 1 2.

Answer:

(a)

Explanation: Integer takes 2 bytes memory and char takes 1 byte memory in c++.

Q.87 The correct output of the following program is

#include<iostream.h>

void main()

{

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

cout<<i<<endl ;

cout<<i ;

}

a) 1 2 3 4 5 6 7 8 9 10 1.

b) 1 2 3 4 5 6 7 8 9 10 10.

c) 1 10.

d) 1 2 3 4 5 6 7 8 9 10.

Answer:

(b)

Explanation: “for loop” print values of i from 1 to 10.

Q.88 The errors in the code below is

#include<iostream.h>

int a=10;

void main()

{

int a=20;

{

int a=30;

cout<< a <<::a<<::::a ;

}

}

a) compiler error.

b) no error.

c) :: and :::: cannot come together.

d) no return statement for main ().

Answer:

(a)

Explanation: “::::” does not exists in c++ and it will give illegal structure declaration.

Q.89 The errors in the code below is

#include<iostream.h>

void main()

{

char c[]=”c++ is easy”;

int i = strlen (c) ;

cout<< i ;

}

a) no error.

b) c cannot be passed as an argument. It should be c[].

c) string .h header file is not defined.

d) no return statement for main ().

Answer:

(c)

Explanation: “string.h” header file has defined string functions in it like strlen, strcpy. These functions cannot be used without using string.h header file.

Q.90 The errors in the code below is

#include<iostream.h>

const int i =10;

void main()

{

const int i =20;

cout<< &i << &::i ;

}

a) compiler error : illegal structure declaration.

b) no error.

c) :: cannot be used with constant.

d) run time error.

Answer:

(a)

Explanation: &::I is a illegal declaration used in the code.

Q.91 The value which can be assigned to char names[6] is

a) aditi.

b) priyanka.

c) amrita.

d) mudita.

Answer:

(a)

Explanation: one space is needed for null character, which acts as a termination symbol.

Q.92 The code “int marks [30]” used in one of the c++ program is

a) not an array.

b) single dimensional array.

c) multi dimensional array.

d) two dimensional array.

Answer:

(b)

Explanation: The syntax of single dimension array is “datatype arrayname[size]” whereas multi dimension arrays are accessed using more than one index. Example names[][]. It can be 2dimensional or 3 dimensional.

Q.93 A character array is also known as

a) character string.

b) array.

c) integer.

d) character.

Answer:

(a)

Explanation: A character array is also known as character string.

Q.94 The data type of an array is known as

a) constant.

b) floating point variable of the array.

c) variable

d) base type of the array.

Answer:

(d)

Explanation: Array is a data structure consisting of a group of elements that are accessed by indexing. Each element of an array has the same data type and the array occupies a contiguous area of storage.

Q.95 The function getline is invoked with

a) cin stream.

b) cout stream.

c) ostream.

d) input stream.

Answer:

(a)

Explanation: getline() is invoked using cin. Example cin.getline(string1,50. String1 is the name of the array and 50 is the number of characters we want this function to read.

Q.96 The function to handle single character from the keyboard is

a) gets().

b) getline().

c) get().

d) put().

Answer:

(c)

Explanation: The get() function is an input function. It fetches the character from the keyboard and stores it in a character variable.

Q.97 The function to handle multiple characters from the keyboard is

a) gets().

b) getline().

c) get().

d) put().

Answer:

(a)

Explanation: The function gets() is a string function and reads a string i.e. multiple characters from the keyboard including white spaces etc.

Q.98 A structure is declared with the keyword

a) structure.

b) struct.

c) define.

d) tag.

Answer:

(b)

Explanation: A structure is declared using keyword struct. Example

struct names

{ int class;

int rollno;

float marks;

char grade;

};

Q.99 When, the structure is defined without a tag, then the numbers of variables that can be declared are

a) two.

b) three.

c) many.

d) only one.

Answer:

(d)

Explanation: One variable is declared when the structure is defined without a tag.

Q.100 An array in a structure

a) can have elements of different data type.

b) always has elements of the same data type.

c) will have elements of the same struct type.

d) can also define a structure within it.

Answer:

(b)

Explanation: An array is a collection of elements of same data type.