CBSE - MCQ Question Banks (के. मा. शि. बो . -प्रश्नमाला )

PreviousNext

Q. 193301 Name the different types of scopes provided by C++.
Right Answer is:

SOLUTION

There are four types of scopes provided by C++: 
1.  Local scope: A local variable scope is restricted to the function that declares the variable.
2.  Function scope: The variables declared in the outermost block of a function have function scope.
3.  File scope: A name declared outside all blocks and functions has file scope.
4.  Class scope: A name of a member has class scope and is local to its class.


Q. 193302 Name the types of function provided by C++.
Right Answer is:

SOLUTION

  The types of functions provided by C++ are: 
1.  User defined functions.
2.  Built in functions.


Q. 193303 Differentiate between definition and declaration of a function.
Right Answer is:

SOLUTION

A function declaration establishes the name of the function and the number and type of its parameters. A function declaration consists of a return type, a name and a parameter list.
A function definition contains a function declaration and body of the function.


Q. 193304 Differentiate between a global variable and a local variable.
Right Answer is:

SOLUTION

Global variables are the variables that are declared outside all functions. These variables can be accessed from outside the function, whereas local variables are the variables which are declared within the body of the function or a block and can be accessed by these functions only.


Q. 193305 Explain the term scope in a program.
Right Answer is:

SOLUTION

Scope are the rules that decide in which part of the program a particular piece of code or data item would be known and can be accessed therein.


Q. 193306 Why is main function special in C++?
Right Answer is:

SOLUTION

Whenever a C++ program is executed, execution of the program starts at main (). The main is the driver function of a program. If it is not present in the program, no execution can take place.


Q. 193307 State the meaning of  gobal prototypes ?
Right Answer is:

SOLUTION

When a function prototype appears before the function definition, it is known as global prototyping.

 


Q. 193308 Why do we require prototypes ?
Right Answer is:

SOLUTION

Prototyping is required as compiler carefully compares each use of function with its prototype to check whether the function is invoked properly.

 


Q. 193309 Give two examples of function prototypes?
Right Answer is:

SOLUTION

i) int val(int n1, int n);
ii) float sum(float a);


Q. 193310 State the general form of the function definition?
Right Answer is:

SOLUTION

datatype function name (parameter list)
{ 

body of the function
}

 


Q. 193311 What are user defined functions?
Right Answer is:

SOLUTION

User defined functions are created by the programmer as per the requirement of the program.

 


Q. 193312 State 2 things as to what should the function Main( ) primarily consist of ?  
Right Answer is:

SOLUTION

Function Main( ) primarily consist of:
a) The data items required and
b) The function calls.


Q. 193313 Define function?
Right Answer is:

SOLUTION

A function in C++ language is a block of code that performs a specific task. It has a name and it is reusable i.e. it can be executed from as many different parts in a C++ program.


Q. 193314 The correct statement is


A. the entire structure may be returned by a function.

B. a function may return a reference to a structure.

C. a function may return the members of a structure.

D. a function may accept the members of a structure.

Right Answer is: C

SOLUTION

In C++ a function may return the members of a structure , Only one value can be returned by a function, either the whole structure or just one member. Here we can pass a structure to a function through call by value as well as call by referenc mechanism.


Q. 193315 The prototype void fun(ABC &, char[]); indicates that arguments are passed by:


A. Value

B. Reference

C. Value, Reference

D. Reference, Value

Right Answer is: B

SOLUTION

The prototype void fun(ABC &, char[]); indicates that arguments are passed by reference. The first argument represents that object is passed as a reference and the second argument is an array of character which by default works on reference. 


Q. 193316 If, function call : fun(a.x,a.y);


A. the members are being passed by reference.

B. the first one is passed by value and the other by reference.

C. the members are being passed by value.

D. we cannot tell how the members are being passed.

Right Answer is: D

SOLUTION

We can tell how variables are being sent through the function prototype or definition. The function call is the same for call by value and by reference.


Q. 193317 It allows to define symbolic constants:


A. #include

B. typedef

C. #define

D. macros

Right Answer is: C

SOLUTION

The #define is a preprocessor directive that allows us to define symbolic names and constants.


Q. 193318 When reference to a structure is passed to a function,


A. any change made is only temporary.

B. changes are made in the original values of the variable.

C. reference to the entire structure can’t be passed.

D. changes cannot be made when reference to a structure is passed.

Right Answer is: B

SOLUTION

In C++ a structure can be passed to a function through "call by value" as well as "call by reference" mechanism. So if we pass a structure through call by reference then the original value can also get changed.


Q. 193319 To not reflect the value of actual object during changes done in the formal argument, pass the structure object as a:


A. Value to the function

B. Reference to the function

C. Pointer to the function

D. Address to the function

Right Answer is: A

SOLUTION

A structure is passed as a value to avoid changes in the actual object during any changes done in the formal argument in a function body.


Q. 193320 The output of the following code snippet is – 
#include< iostream.h > 
struct Pt
{
   int x,y;
};
void disp(Pt p)
{
  cout << " "<< p.x <<" " << p.y;  
}
void main()
{
  Pt A,B,C={25,50};
  A=C;
  C.x+=5;
  B=C;
  B.y+=10;
  
A.x=22; 
  disp(A);
  disp(B);
  disp(C);
}  


A. 22 50 30 60 25 50

B. 22 50 30 60 30 50

C. 25 50 25 60 30 50

D. 25 50 30 60 30 50

Right Answer is: B

SOLUTION

The given code has been executed in such a way - #include< iostream.h > 
struct Pt
{
   int x,y;
};
void disp(Pt p)
{
  cout << " "<< p.x <<" " << p.y;  
}
void main()
{
 Pt A,B,C={25,50};//values of x and y for A,B and C structure variable
 A=C;                //values of x and y of C assigned to the x and y of A
 C.x+=5;         //x of C =30 
 B=C;               //values of x and y of C assigned to B
 B.y+=10;      // y of B = 60
 A.x=22;        //x of A = 22
 disp(A);        // calling disp() function and A has passed into it 
 disp(B);       // calling disp() function and B has passed into it   disp(C);       // calling disp() function and C has passed into it 
}   The output of the code is 22 50 30 60 30 50


Q. 193321 Given the following lines of code,
struct newemp
{
      int code;       char name[20]; }; newemp NE[25];   In order to access the data of the third employee in the list, use  


A. NE[i].code and NE[i].name

B. NE[4].code and NE[4].name

C. NE[3].code and NE[3].name

D. NE[2].code and NE[2].name

Right Answer is: D

SOLUTION

To access the third element of the list we can use the statement- NE[2].code and NE[2].name


Q. 193322 The most appropriate statement regarding:
     EMP[45].salary.tax  is that


A. it is an array of structure.

B. it is a nested structure with an array.

C. it is an array of nested structure.

D. the nested structure has an array.

Right Answer is: C

SOLUTION

EMP[45].salary.tax statement is an array of nested structure.


Q. 193323 # in a C++ program signifies a


A. link file.

B. execution file.

C. preprocessor directive.

D. batch file.

Right Answer is: C

SOLUTION

A # sign in the beginning of a statement means, it is a preprocessor directive, i.e., the instructions given here will be processed before the program is compiled.


Q. 193324 Nested structures are also called as


A. referencing structures.

B. complex structures.

C. recursive structures.

D. looping structures.

Right Answer is: B

SOLUTION

A structure inside another structure is called as nested structure.


Q. 193325 Given function prototype: void fun (ABC &, char []); then,


A. structure variable will be passed by reference, the array by value.

B. structure variable and the array will be passed by reference.

C. structure variable will be passed by value, the array by reference.

D. structure variable and the array will be passed by value.

Right Answer is: A

SOLUTION

For ABC, a reference variable is being used while for char, it is being passed by value.


Q. 193326 After the statement, typedef float money; the one that will generate an error is


A. money membership;

B. float charges;

C. typedef salary amount;

D. typedef money fees;

Right Answer is: C

SOLUTION

typedef salary amount cannot be used because salary is not a fundamental data type.


Q. 193327 The difference between const and macro is that


A. macro replaces a value in the code while, const will declare a variable.

B. macro replaces after compilation while, const is done during compilation.

C. macro substitution may affect size of the EXE file but, not the stack.

D. cost substitution may affect size of the EXE file but, not the stack.

Right Answer is: C

SOLUTION

Macros always replace the value of a variable before compilation, while const acts like a simple constant during the compilation.


Q. 193328 A self-referential structure is


A. a structure inside a structure.

B. a structure that calls itself.

C. a pointer referencing to itself.

D. a pointer inside a structure.

Right Answer is: C

SOLUTION

A self-referential structure has an element that, refers to the structure itself. This is actually a pointer that points to a structure of the same type.


Q. 193329 While declaring a structure , the keyword struct is followed by


A. tag.

B. Variable.

C. Member name.

D. ;

Right Answer is: A

SOLUTION

Tag is the name of the structure, which is being declared after the keyword struct.


Q. 193330 When a pointer to a structure is incremented,


A. one more structure member is formed.

B. it is incremented by the size of the structure.

C. there is no change in the pointer.

D. pointer creates one more reference to the structure.

Right Answer is: B

SOLUTION

The pointer gets incremented by the size of the structure.


Q. 193331 A structure can contain


A. functions.

B. data and functions.

C. data and function prototype.

D. data only.

Right Answer is: D

SOLUTION

A structure can contain only the data while both data and functions are included in a class.


Q. 193332 A structure is a


A. homogeneous data structure.

B. heterogeneous data structure.

C. homogeneous data type.

D. heterogeneous data type.

Right Answer is: B

SOLUTION

A structure is a heterogeneous data structure since, it stores different types of data.


Q. 193333 The one which can access a variable in structure *b is


A. b > var

B. b - > var

C. b.var

D. var.b

Right Answer is: B

SOLUTION

var is a pointer , so to access it b- > var is used.


Q. 193334 sqrt( ) and cos( ) are examples of


A. computational functions.

B. manipulative functions.

C. procedural functions.

D. void functions.

Right Answer is: A

SOLUTION

The functions that calculate or compute some value and return the computed value are computational functions.


Q. 193335 Arrays are


A. passed as value generally.

B. passed as reference.

C. cannot be passed.

D. passed by value and reference both.

Right Answer is: B

SOLUTION

In call by reference, instead of passing a value to the function being called, a reference to the original variable is passed.


Q. 193336 The specifier which specifies that a variable has already been defined in the program is


A. extern.

B. static.

C. register.

D. auto.

Right Answer is: A

SOLUTION

extern is used when we have defined the variable elsewhere, and use that variable in our program.


Q. 193337 Permanent change in memory address is made by


A. call by reference.

B. call by value.

C. changing parameter.

D. changing argument.

Right Answer is: A

SOLUTION

In call by reference, the changes are reflected back to the original values.


Q. 193338 exit ( ) function is an example of


A. computational function.

B. mathematical function.

C. manipulative function.

D. procedural function.

Right Answer is: D

SOLUTION

Functions that perform an action and have no explicit return value are procedural functions.


Q. 193339 Reference to a function


A. cannot be passed as arguments.

B. can be passed as arguments.

C. can not be passed in a C++ program.

D. works with the copy of original values rather than original values.

Right Answer is: B

SOLUTION

When a function is called by reference, then the formal parameters become references to the actual parameters in the calling function.


Q. 193340 Type function name(,,,) is...


A. a open parameter list.

B. a closed parameter list.

C. not a parameter list.

D. none of the above.

Right Answer is: A

SOLUTION

In above function as type and number of parameters are not specified so it is considered as open parameter list.


Q. 193341 Arrays and pointers are


A. not related to each other.

B. closely related to each other.

C. are equivalent to each other.

D. fundamental data types.

Right Answer is: B

SOLUTION

Arrays and pointers are derived data types. an array can hold multiple elements of same data type.


Q. 193342 How can a function be invoked in a program?
A. not related to each other.
B. closely related to each other.
C. are equivalent to each other.
D. fundamental data types.

Right Answer is:

SOLUTION

A function is invoked by providing its function name, followed by the parameters.


Q. 193343 What is the use of void data type?
A. not related to each other.
B. closely related to each other.
C. are equivalent to each other.
D. fundamental data types.

Right Answer is:

SOLUTION

‘Void’ data type is used for empty set of values.


Q. 193344 Can constants or expressions be passed by reference?
A. not related to each other.
B. closely related to each other.
C. are equivalent to each other.
D. fundamental data types.

Right Answer is:

SOLUTION

No, constants or expressions cannot be passed by reference.


Q. 193345  What are user defined functions?
A. not related to each other.
B. closely related to each other.
C. are equivalent to each other.
D. fundamental data types.

Right Answer is:

SOLUTION

 User defined functions are created by the programmer as per the requirement of the program.


Q. 193346  What is the difference between a function declaration and function definition ?
A. not related to each other.
B. closely related to each other.
C. are equivalent to each other.
D. fundamental data types.

Right Answer is:

SOLUTION

 A prototype has no body and no code.In other words, a (prototype) declaration introduces a function name to the program. On the other hand, a definition tells the Program, what is the function doing and how is it doing so.

 


Q. 193347 State the general form of  the function definition.
A. not related to each other.
B. closely related to each other.
C. are equivalent to each other.
D. fundamental data types.

Right Answer is:

SOLUTION

 return-type function name (parameter list)

       {        
       body of the function

}


Q. 193348  Define function.
A. not related to each other.
B. closely related to each other.
C. are equivalent to each other.
D. fundamental data types.

Right Answer is:

SOLUTION

 A function is a subprogram that acts on data and often returns a value.


Q. 193349 Name two parameters that appear while calling the function statement.
A. not related to each other.
B. closely related to each other.
C. are equivalent to each other.
D. fundamental data types.

Right Answer is:

SOLUTION

 The two main parameters that appears while calling a function are:
1. Actual parameter 
2. Formal parameter


Q. 193350 Which keyword is used to make an argument constant?
A. not related to each other.
B. closely related to each other.
C. are equivalent to each other.
D. fundamental data types.

Right Answer is:

SOLUTION

The keyword that is used to make an argument constant is ‘Constant’.


Q. 193351 Does an argument have default values?
A. not related to each other.
B. closely related to each other.
C. are equivalent to each other.
D. fundamental data types.

Right Answer is:

SOLUTION

Yes, an argument can have default values.


Q. 193352 Give the syntax of the function that does not return a value.
A. not related to each other.
B. closely related to each other.
C. are equivalent to each other.
D. fundamental data types.

Right Answer is:

SOLUTION

Syntax: void function-name (parameter list);


Q. 193353 Who determines the scope of a function?
A. not related to each other.
B. closely related to each other.
C. are equivalent to each other.
D. fundamental data types.

Right Answer is:

SOLUTION

The place of function or variable declaration determines its scope.


Q. 193354 A structure is declared with the keyword


A. structure

B. struct

C. define

D. tag

Right Answer is: B

SOLUTION

Structure is a user define data structure that is a collection of various types of data elements. The struct keyword is used to declare the structure.


Q. 193355 A preprocessor directive


A. begins with /*  and ends with a */

B. begins with # and ends with ;

C. begins with # and ends without ;

D. begins with { and ends with );

Right Answer is: C

SOLUTION

The C++ preprocessor is a program that is executed before the source code is compiled. It always begins with a hash "#" and ends without a semicolon ";"


Q. 193356 The given code will show an error in the line:
# include< iostream.h>
void main()
{
struct employee
{
char name[25];
int age;
int salary;
};
employee emp;
strcpy(emp.name,"rohan");
emp.age=37;
cout << name;
cout << emp.age;
}


A. emp.age=37;

B. cout << name;

C. strcpy(emp.name,"rohan");

D. employee emp;

Right Answer is: B

SOLUTION

name is the member of the structure "employee". so to access any member of a structure we need to use structure variable with the dot operator. So the correct statement will be - cout << emp.name;


Q. 193357 Reena tried to compiled the given code in C++ compiler but it generated errors. Then she found the error in the lines
#include< iostream.h >
void main ( )
{
struct Student
{
char stu_name[20];
char stu_sex;
int stu_age = 17;
} st ;
gets(stu_name);
gets(stu_sex);
}


A. gets(stu_name);
gets(stu_sex);
int stu_age = 17;

B. int stu_age = 17;

C. gets(stu_name);
gets(stu_sex);

D. gets(stu_name);

 

Right Answer is: A

SOLUTION

stu_name and stu_sex are the members of the structure "Student". so to access it we need to use structure variable i.e. "st". In a structure we can declare the members only but we cannot initialize it.


Q. 193358 When a structure is defined within main() , structure variables


A. cannot be accessed  within main( )

B. can be returned by a function

C. can be passed to any function

D. can be accessed only within main( )

Right Answer is: D

SOLUTION

If declared within main() it becomes local to the function main().  


Q. 193359 The output of the following code will be:

#include < iostream.h >
struct Sumval
{
int a,b;
}
void Struct_Fun(Sumval Sv)
{
Sv.b = 2.5;
cout<< Sv.a << Sv.b;
}
void main ( )
{
Sumval Sv;
Sv.a=100;
Sv.b=1.5;
Struct_Fun(Sv);
cout<< Sv.a << Sv.b;
}


A. 10021001

B. 10021100

C. 10011002

D. 20010012

Right Answer is: A

SOLUTION

The program will execute as follows - #include < iostream.h >
struct Sumval
{
int a,b;
}
void Struct_Fun(Sumval Sv)
{
Sv.b = 2.5;
cout<< Sv.a << Sv.b;
}
void main ( )
{
Sumval Sv;
Sv.a=100;
Sv.b=1.5;
Struct_Fun(Sv); // calling Struct_Fun function
cout<< Sv.a << Sv.b;
}   The output will be - 10021001


Q. 193360 The keyword typedef can be used


A. with any data type.

B. only with fundamental data types.

C. only with user defined data types.

D. only with float data type.

Right Answer is: A

SOLUTION

C++ allows us to define explicitly new data type names by using the keyword typedef. The typedef does not actually create a new data class, rather it defines a new name for an existing type. It can be used with any data type.


Q. 193361 The keyword typedef is used to


A. create a new user defined structure

B. create a new data type

C. create an alias for an existing data type

D. create new variables for an existing data type

Right Answer is: C

SOLUTION

C++ allows us to define explicitly new data type names by using the keyword typedef. Using typedef does not actually create a new data class, rather it defines a new name for an existing type. The syntax to create an alias for the int data type is - typedef int id; Here id is an alias for int data type.


Q. 193362 Ravi has implemented a statement i.e. typedef float money; in the program. Now the next statement that will generate an error is


A. money membership;

B. float charges;

C. typedef salary amount;

D. typedef money fees;

Right Answer is: C

SOLUTION

The statement "typedef salary amount;" will generate an error as salary is not a data type. Here we can use only the fundamental or basic data types of C++.


Q. 193363 Which of the given options would make the statement incorrect?
"An array of structures has elements ...”


A. of different data types.

B. of the same data type.

C. made of different data types.

D. that are structures.

Right Answer is: A

SOLUTION

 An array always has elements of the same data type  


Q. 193364 While accessing structure members, the item to the right of the dot is


A. structure variable name

B. structure name

C. subscript value

D. structure member name

Right Answer is: D

SOLUTION

The syntax to access the members of the structure is - structure-variable.member-name  


Q. 193365 The significance of typedef keyword is that


A. code becomes short.

B. code compiles successfully.

C. code runs successfully.

D. the code becomes easier to read and understand.

Right Answer is: D

SOLUTION

Using typedef keyword we can make the code easier to read and understand.


Q. 193366 which the following below?


A. None

B. v

C. vi

D. vii

Right Answer is: C

SOLUTION

vi, values cannot be assigned this way to a declared structure  variable.


Q. 193367 The error in the following given code is -
struct A
{
int x=2;
char z=’A’;
};
A a;
a.x=12;
a.z=’Z’;


A.  

that the struct is not a keyword.

 

B. that the values of x and z in A are being overwritten.

C. that the member z has a value same as the structure name.

D. that the x and z cannot be assigned values in definition.

Right Answer is: D

SOLUTION

In C++ we can declare members of a structure only. we cannot initialize it.


Q. 193368 Consider the structure below-
struct A
{
  int x; 
  int y;
 char z;
};
A a1,*a2; The correct statement to access the variable 'x' using either of the structure variable is -


A. a1.x  or  a2.x

B. a1.x  or  a2->x

C. a1->x  or  a2.x

D. a1->x  or  a2->x

Right Answer is: B

SOLUTION

a1.x  or  a2->x, a2 is a pointer variable hence uses -> to access the member


Q. 193369 A structure definition has been given below - struct A
{
int x;
int y;
char z;
};

struct B
{
int r;
A mn;
};
B vb; The correct statement to access r and x using "vb" structure variable is -


A. vb.r and mn.x

B. B.vb.r and B.vb.x

C. B.vb.r and
A.mn.x

D. vb.r and vb.mn.x

Right Answer is: D

SOLUTION

vb is the variable of B structure and mn is the nested variable of A structure. The statement to access r which is the member of B structure is - vb.r The statement to access x which is the member of A structure is - vb.mn.x


Q. 193370 An alias for structure tag name can also be defined using


A. int.

B. array.

C. float.

D. typedef.  

 

Right Answer is: D

SOLUTION

An alias for structure tag name can be defined using typedef keyword. It defines another name for the structure tag name.


Q. 193371 Given the following structure definition, how will you display complete name of person P1? struct name{   char title[5];   char fname[10];   char lname[10]; }; struct person{   int code;   name p;  }; person P1;


A. cout<< P1.title<< P1.fname<< P1.lname;

B. cout<< p.title<< p.fname<< p.lname;

C. cout<< P1.p.title<< P1.p.fname<< P1.p.lname;

D. cout<< P1.p.title<< p.fname<< p.lname;

Right Answer is: C

SOLUTION

As p1 is the structure variable of person and p is the structure variable of name. The correct statement to display the name is - cout<


Q. 193372 The program which get executed before the source program is  


A. preprocessor.

B. build-in functions.

C. user-defined functions.

D. module.  

Right Answer is: A

SOLUTION

The preprocessing phase of a C++ program occurs before a program is compiled. The C++ preprocessor is a program that is executed before the source code is compiled.


Q. 193373 The difference between const and macro is that the


A. macro replaces a value in the code while const will declare a variable.

B. macro substitution may affect size of the EXE file but not the stack.

C. const substitution may affect size of the EXE file but not the stack.

D. macro and const replaces values during execution.

Right Answer is: A

SOLUTION

macro replaces value before compilation while const will declare a variable during compilation


Q. 193374 A structure can be assigned to another structure, if


A. both are of the same data type.

B. both have members of the same data type.

C. tag was omitted while defining the structures.

D. both of them don’t contain arrays.

Right Answer is: A

SOLUTION

v1=v2 will work only, when both are of the same data type.


Q. 193375 If a structure is defined within main() , structure variables


A. cannot be accessed within main( ).

B. can be returned by a function.

C. can be passed to any function.

D. can be accessed only within main( ).

Right Answer is: D

SOLUTION

If declared within main(), it becomes local to the function main().


Q. 193376 The keyword typedef can be used


A. with any data type.

B. only with fundamental data types.

C. only with user defined data types.

D. only with float data type.

Right Answer is: A

SOLUTION

typedef is used to give an alias name to the existing data types.


Q. 193377 To pass a structure to a function, by value


A. pass a reference to it.

B. pass its address using a pointer variable.

C. pass it as a structure variable.

D. pass it as an array.

Right Answer is: C

SOLUTION

Since, the structure variable belong to the structure data type. Therefore, it has to be passed in the form of a structure.


Q. 193378 The error in the given code is:
#include< iostream.h >
void main ( )
{
struct Student
{
char stu_name[20];
char stu_sex;
int stu_age = 17;
} student ;
gets(stu_name);
gets(stu_sex);
}


A. gets(stu_name);
gets(stu_sex);
int stu_age = 17
;

B. int stu_age = 17;

C. gets(stu_name);
gets(stu_sex);

D. gets(stu_name);

Right Answer is: A

SOLUTION

gets( stu_name); because methods are accessed with dot operator.
int age=17; because, we cannot initialize variables within a structure.


Q. 193379 The line having an error in the code below is:
# include< iostream.h>
void main()
{
struct employee
{
char name[25];
int age;
int salary;
};
employee emp;
strcpy(emp.name,"rohan");
emp.age=37;
cout << name;
cout << emp.age;
}


A. emp.age=37;

B. cout << name;

C. strcpy(emp.name,"rohan");

D. employee emp;

Right Answer is: B

SOLUTION

it should be cout << emp.name.


Q. 193380 When accessing a structure member, the identifier on the left hand side of the dot operator, is the name of


A. a structure member.

B. a structure tag.

C. a structure variable.

D. the keyword struct.

Right Answer is: C

SOLUTION

The dot operator has a structure variable on the left and structure member on the right side.


Q. 193381 To define a structure


A. give keyword struct, followed by tag, followed by members within braces.

B. give keyword structure, followed by members within braces.

C. give keyword struct, followed by the tag and members, within braces.

D. give tag, followed by members within braces.

Right Answer is: A

SOLUTION

The syntax for structure declaration is :     struct structure_name {
   member_type1 member_name1;
   member_type2 member_name2;
   member_type3 member_name3;
    .
    .
    } object_names;


Q. 193382 Given the following lines of code,
struct newemp
{
int code; 
char name[20]; }; newemp NE[25]; In order to access the data of the third employee in the list, we use


A. NE[i].code and NE[i].name

B. NE[4].code and NE[4].name

C. NE[3].code and NE[3].name

D. NE[2].code and NE[2].name

Right Answer is: D

SOLUTION

Any array starts from index 0. So, the third employee’s details can be obtained by NE[2].name and NE[2].code.


Q. 193383 The error in the code given below is:
struct A
{
int x=2;
char z=’A’;
};
A a;
a.x=12;
a.z=’Z’;


A. No error.

B. Values of x and z in A are being overwritten.

C. Member z has a value same as the structure name.

D. x and z cannot be assigned values in definition.

Right Answer is: D

SOLUTION

Variables are never initialized during a structure declaration.


Q. 193384 Given the following structure, the command to access r and x in vb is
struct A
{
int x;
int y;
char z;
};

struct B
{
int r;
A mn;
};
B vb;


A. vb.r and mn.x.

B. B.vb.r and B.vb.x.

C. B.vb.r and
A.mn.x.

D. vb.r and vb.mn.x.

Right Answer is: D

SOLUTION

r is the member of structure B and x is a member of structure A, which has been nested inside B.


Q. 193385 The error in the below code is
struct
{
int x=10;
int y;
char z[10];
}a1,a2;


A. There is a character array as a member.

B. When tag is missing, only one variable can be declared.

C. x value cannot be defined in the structure.

D. Without tag name, variables cannot be declared.

Right Answer is: C

SOLUTION

A value can never be assigned inside a structure.


Q. 193386 Given the following structure definition, the command to display complete name of person P1 is
             struct name{ char title[5]; char fname[10]; char lname[10]; }; struct person{ int code; name p; }; person P1;


A. cout<< P1.title<< P1.fname<< P1.lname;

B. cout<< p.title<< p.fname<< p.lname;

C. cout<< P1.p.title<< P1.p.fname<< P1.p.lname;

D. cout<< P1.p.title<< p.fname<< p.lname;

Right Answer is: C

SOLUTION

P1 is an instance of structure person which, includes name which in itself is another structure. So, complete access can be done by the statement 
       P1.p.title, P1.p.fname, P1.p.lname


Q. 193387 The output of the following code snippet is
#include< iostream.h >
struct Pt
{
int x,y;
};
void disp(Pt p)
{
cout << ' '<< p.x <<' ' << p.y;
}
void main()
{
Pt A,B,C={25,50};
A=C;
C.x+=5;
B=C;
B.y+=10;

A.x=22;
disp(A);
disp(B);
disp(C);
}


A. 22 50 30 60 25 50

B. 22 50 30 60 30 50

C. 25 50 25 60 30 50

D. 25 50 30 60 30 50

Right Answer is: B

SOLUTION

The sequence of calling functions is : disp (A); disp (B); disp (C);, and the output is displayed according to this sequence.


Q. 193388 The error in the following structure definition, is
struct size { 
int breadth; int height; }


A. structure size

B. int length, breadth, height;

C. }s1

D. };

Right Answer is: D

SOLUTION

A semicolon should always terminate a structure.


Q. 193389 The invalid statement among the ones given below is


A. The entire structure may be returned by a function.

B. A function may return a reference to a structure.

C. A function may return the members of a structure.

D. A function may accept the members of a structure.

Right Answer is: C

SOLUTION

A function may return the members of a structure, Only one value can be returned by a function, either the whole structure or just one member.


Q. 193390 The error in the following structure definition, is 
struct 
{ int x;
int y; char c; } var1, var2, var3;


A. struct abc{int x;

B. char c[20];

C. };

D. }var1;

Right Answer is: D

SOLUTION

When tag is missing, only one variable can be declared. Here, three have been declared and this is wrong.


Q. 193391 The number of variables, that can be declared when structure is defined without a tag is


A. one.

B. none.

C. many.

D. two.

Right Answer is: A

SOLUTION

While declaring a structure without a tag, only one variable can be declared.


Q. 193392 To add a new name to an existing data type, we can use


A. arrays.

B. nested structure.

C. typedef.

D. # define preprocessor.

Right Answer is: C

SOLUTION

typedef defines new name in addition to the existing type name. It does not replace the standard data type name.


Q. 193393 A structure within a structure is called


A. enclosed structure.

B. nested structure.

C. doubled structure.

D. single structure.

Right Answer is: B

SOLUTION

Nested structures contain structures within structures. A structure element may be either complex or simple. The simple elements are any of the fundamental data types of C++ i.e., int, char, float, double. However, a structure may consist of an element that itself is complex i.e., it is made up of fundamental types, e.g., arrays, structures etc.


Q. 193394 What are the total number of elements in the following declared array 'x'- int x[5] [6];


A. 5 elements.

B. 11 elements.

C. 30 elements.

D. 60 elements.

Right Answer is: D

SOLUTION

The total number of elements of a two-dimensional array is get calculated by using the formula - Total_no_of_elements = no_of_rows x no_of_columns. So here the total number of elements is 30.


Q. 193395 int marks [35] has


A. 0 to 35 subscripts.

B. 0 to 34 subscripts.

C. 1 to 35 subscripts.

D. 1 to 34 subscripts.

Right Answer is: B

SOLUTION

An array marks of type int with 35 elements will have marks[0] at the first allocated memory location with last subscripts as 34.


Q. 193396 An array of characters is terminated by a


A. 'z' character.

B. null character.

C. 'x' character.

D. char character.

Right Answer is: B

SOLUTION

A string is defined as a character array that is terminated by a null character. Therefore, the char array are declared one character longer to hold null at the end.


Q. 193397 The simplest form of a multi-dimensional array is


A. null-dimensional array.

B. three-dimensional array.

C. single-dimensional array.

D. two-dimensional array.

Right Answer is: D

SOLUTION

Two-dimensional array is the simplest form of multi-dimensional array. It has two dimensions, one represents the row and another represents the column.


Q. 193398 In the declaration of an array "Type" declares the


A. base type of the array.

B. size of the array.

C. elements of the array.

D. name of the array.

Right Answer is: A

SOLUTION

The syntax of an array declaration is - type array-name[size], Here "type" declares the base type of the array, which is the type of each elements of the array.


Q. 193399 An array is of


A. three types.

B. only one type.

C. two types.

D. four types. 

Right Answer is: C

SOLUTION

An array is a collection of variables of the same type that are referenced by a common name. It is of two type i.e. single-dimensional array and multi-dimensional array.


Q. 193400 Subscript is the


A. element number written within [ ] .

B. type of an array.

C. header file for an array.

D. object of iostream.

Right Answer is: A

SOLUTION

Subscripts is used either to retrieve the value of one or more array elements or to allow array elements to receive new values.


PreviousNext