Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

19101.

Identify the errors in the following structure definition and write the reason for each:struct{int roll, age;float fee= 1000:};

Answer»

Errors 

(1) No name for the structure.

The correct structure is as follows

struct student

{

short roll.age:;

float fee=1000;

}

19102.

“Its value does not change during execution”. What is it?

Answer»

It is Constant 

19103.

int *P; p is having the address 2340. What will be the value of P after the execution of the statements P++; P = P – 3; (a) 2340 (b) 2342 (c) 2338 (d) 2332

Answer»

Correct answer is  (d) 2332

19104.

Read the C++ statements given below and answer the following questions:int ar[] = {34,12, 25,56, 38};int *p = ar; (a) What will be the content of p? (b) What is the output of the expression: *p + *(ar+2)? (c) The statement ar++; is invalid. Why? How does it differ from p++;?

Answer»

(a) 34 

(b) *p=34 and *(ar+2)=25

then *p+*(ar+2)=34+25=59. 

(c) ar++ is invalid but p++ valid, p is the pointer, pointer arithmetic is allowed.

19105.

From the following which data type uses 4 bytes of memory (a) float (b) short (c) char (d) double

Answer»

float data type uses 4 bytes of memory

19106.

Identify the errors in the following C++ code segment and give the reason for each.int p, *q a=5; float b2;p=&a;cout<<p<<*p<<*a;if(p<q)colLit<<p;cout<<cp*a;

Answer»

Following are the errors 

(1) Here q is an integer pointer it can not store the address of oat variable b. 

(2) Cannot print *a. 

(3) The pointers p and q are different data types so cannot use relational operator.

The correct code is as given below.

#include<iostream>

using namespace std;

int main()

{

int *p,a=5,*q,b=2;

p=&a;

q=&b;

cout<<p<<*q<<a;

if(p!=q)cout<<p;

cout<<*p*a;

}

19107.

char data type uses ..... bytes of memory(a) 1 (b) 3 (c) 7 (d) 8

Answer»

char data type uses 1 bytes of memory

19108.

Ramu wants to store the value of From the following which is correct declaration (а) char pi = 3.14157 (b) int pi = 3.14157 (c) float pi = 3.14157 (d) long pi = 3.14157

Answer»

(c) float pi = 3.14157.

19109.

Alvin wants to store the value of π From the following which is correct declaration (a) char pi = 3.14157 (b) const int pi = 3.14157 (c) const oat pi = 3.14157(d) long pi = 3.14157

Answer»

(c) const oat pi = 3.14157

19110.

Reserved words for the compiler is ........(a) Literals (b) Identier (c) Keywords (d) None of these

Answer»

(c) Key words.

19111.

Pick the invalid identifier (a) name (b) Date of birth (c) age (d) joining_time

Answer»

(b) Date of birth, because it contains space.

19112.

Memory size and sign can be changed using ........ with fundamental data types.

Answer»

Type modifiers.

19113.

Integer data type uses ........ bytes of memory.(a) 5 (b) 2 (c) 3 (d) 4

Answer»

Integer data type uses 2 bytes of memory.

19114.

Read the following C++ statements:int * p, a=5p=&amp;a; (a) What is the speciality of the variable p? (b) What will be the content of p after the execution of the second statement? (c) How do the expressions *p+1 and* (p+1) differ?

Answer»

(a) p is special variable and it is called a pointer.

(b) p contains the address of the variable a

(c) #include<iostream>

using namespace std;

int main ()

{

int *p,a=5;

p=&a;

cout<<*p+1<<endI;

cout<<*(p+1);

}

Here p+1 returns (address of the variable a) +4(4 is the size of int data type in Geany C++). *(p+1) returns the content of this next address location.

19115.

Differentiate static and dynamic memory allocation.

Answer»

When the amount of memory to be allocated is known in advance and memory is allocated during compilation itself, it is referred to as static memory allocation. When the amount of memory to be allocated is not known in advance and it is required to allocate memory as and when required during run time, it is known as dynamic memory allocation.

19116.

&amp; p means …….. (a) address of p (b) value of p (c) address of variable pointed to which p points(d) value of variable to which p points

Answer»

& p means address of p

19117.

The address of a computer memory starts at ……… (a) 0 (b) 1 (c) 1024 (d) none of these

Answer»

Correct answer is (a) 0

19118.

“Structure is a user defined data type”. Justify this statement with the help of an example.

Answer»

Yes it is true. A user can give define according to his needs.

#include<iostream>

using namespace std;

struct date

{

int dd,mm,yyyy;

date*ptr;

};

int main()

{

date *ptr;

ptr = new date;

ptr->dd=28

ptr->mm=6;

ptr->yyyy=1983;

cout<<"Your date of Birth is"<<ptr<<"/"<<ptr->mm<<"/"<<ptr->yyyy;

delete ptr;

}

19119.

Pick an identifier from the following.(а) auto (b) age (c) float (d) double

Answer»

(b) age an identifier

19120.

Read the following statements: (i) While defining a structure in C++, tag may be omitted. (ii) The data contained in a structure variable can be copied into another variable only if both of them are declared using the same structure tag.(iii) Elements of a structure is referenced by structure_name. element (iv) A structure can contain another structure. Now,Choose the correct option from the following: (a) Statements (i) and (ii) are true (b) Statements (ii) and (iv) are true (c) Statements (i), (ii) and (iv) are true (d) Statements (i) and (iii) are true jtyg

Answer»

(d) Statements (i) and (iii) are true.

19121.

Sheela wants to store her age. From the following which is the exact data type.(a) void(b) char (c) int (d) double

Answer»

int is the exact data type

19122.

The address of operator (&amp;) is used for (a) Obtaining R-Value of a variable (b) Obtaining L-Value of a variable (c) Obtaining content of a variable (d) None of these

Answer»

(b) Obtaining L-Value of a variable

19123.

The data used in computers are different. To differentiate the nature and size of data ...... is used.

Answer»

The data used in computers are different. To differentiate the nature and size of data Data types is used.

19124.

S[0] is not equal to S[0] (a) *(S+0) (b) *S (c) *(s) (d) S

Answer»

Correct answer is (d) S

19125.

*p means ………. (a) address of p (b) value of p (c) address of variable pointed to which p points (d) value of virile to which p points

Answer»

Correct answer is (a) address of p

19126.

Classify the following data types. 1. int 2. array 3. function 4. char 5. pointer 6. void 7. float 8. double 9. structure

Answer»
   Fundamental data types   Derived data types
intarray
floatfunction
doublepointer
voidstructure
char
19127.

Explain the use of for loop with an appropriate example.

Answer»

For loop is used to execute a statement more than once.

19128.

Select the structure member operator. Structure member operator select (a) * (b) . (c) ® (d) [ ]

Answer»

Correct answer is (b) .

19129.

Which of the following declaration is valid? (a) int*p = &amp;a, (b) int&amp;p = *a, (c) int &amp;p = &amp;a, (d) int a = &amp;p;

Answer»

Correct answer is (a) int*p = &a,

19130.

In the declaration void (int &amp;, oat &amp;); the parameters are passed by ……. (a) reference (b) value (c) pointers (d) default

Answer»

Correct answer is (a) reference

19131.

A structure brings together a group of (a) Items of the same data type (b) Integers with user defined names. (c) Related data items and functions, if needed. (d) None of the above

Answer»

(c) Related data items and functions, if needed.

19132.

Read the following statements: (i) While defining a structure in C++, tag may be omitted.(ii) The data contained in a structure variable can be copied into another variable only if both of them are declared using the same structure tag.(iii) Elements of a structure is referenced by structure_name. element (iv) A structure can contain another structure.Now, Choose the correct option from the following: (a) Statements (i) and (ii) are true (b) Statements (ii) and (iv) are true (e) Statements (i), (ii) and (iv) are true(d) Statements (i) and (iii) are true

Answer»

(d) Statements (i) and (iii) are true

19133.

Which one of the following is not correct about a pointer. (a) A pointer stores address (b) A Pointer stores L-value of a variable (c) A Pointer points to a memory location (d) A pointer stores R-Value of a variable

Answer»

(d) A pointer stores R-Value of a variable

19134.

Orphaned memory blocks are undesirable. How can they be avoidedORDiscuss problems created by memory leaks.

Answer»

Proper use of delete operator is heeded

OR 

(1) It causes orphaned memory blocks 

(2) wastage of memory 

(3) insufficient memory 

(4) due to this sometimes system may be hanged

19135.

Pick the odd one out from the following. (a) int (b) struct (c) char (d) long

Answer»

Correct answer is (b) struct

19136.

Name the unary operator that returns the address of its operand.

Answer»

& operator. Operator (Address operator)

19137.

The address of the first byte is known as (a) start (b) Base address (c) int address (d) none of these

Answer»

Correct answer is (b) Base address

19138.

……… keyword is used to specify a structure.

Answer»

struct keyword is used to specify a structure.

19139.

Write a declaration for an array of 8 pointers to float float values (a) float a [] (b) float*[*a] [8] (c) float *a[8] (d) float [*a][8]

Answer»

 Correct answer is (b) float*[*a] [8] 

19140.

Choose the correct syntax for accessing a structure element. (a) structure_name.element_name; (b) element_name.structure_name;(c) structure_variable.element_name; (d) element_name.structure_variable;

Answer»

(c) structure_variable.element_name;

19141.

What are the free store operators?

Answer»

‘new’ and ‘delete’ operators.

19142.

Structure within a structure is termed as ......

Answer»

Nested structure

19143.

Represent the names of 12 months as an array of strings.ORA structure can contain another structure. Discuss.

Answer»

char month(1 2)[]={ “Jan”,”Feb”,”Mar”, “Apr”,May”,“Jun”,”July”,”Aug”, “Sep”,Oct”,“Nov”,”Dec”};

OR

Yes It is possible. This is called nested structure.

Eg.

struct date

{

short day,month,year

};

struct student

{

int reg_no;

char name[40];

date dob;

};

19144.

A program is implemented to find the area of a circle and area of a rectangle with two functions having same name but with different signature.(a) Name the concept (b) Explain this concept by writing the above program.

Answer»

(a) Polymorphism

(b) #include<iostream>

#include<cmath>

using namespace std;

float area(float r)

{

return(3.14*pow(r,2));

}

int area(int I, int b)

{

return(I*b);

}
void main ()

{

float r,Ac;

int I,b,Ar;

cout <<"Enter the radius of the circle";

cin>>r;

AC = area(r);

cout <<"Enter the length and breadth";

cin>>I>>b;

Ar = area(I,b);

cout<<"Area of circle is"<<Ac;

cout<<"\n area of rectangle is"<<Ar;

}

Here the function names are same but the return type and number of parameters are different hence distinguish the functions.

19145.

A pointer to void can hold pointers to …………. (a) void (b) int (c) oat (d) any data type

Answer»

Correct answer is (d) any data type

19146.

Which among the following operators cannot be used with pointers? (a) + (b) – (c) / (d) None of these

Answer»

Correct answer is (c) /

19147.

Compare the following two statements, inta=5;int*a=newint(5);

Answer»

int a=5; This means ‘a’ is an integer variable that is initialized with the integer value 5. int *a=new int(5). Here ‘a’ is a pointer variable and it allocates memory dynamically and stores a value 5.

19148.

Name a method used to put logically related elements in one unit.

Answer»

Structure or class used to put logically related elements in one unit.

19149.

Give the syntax of new operator.

Answer»

= new ; 

eg: int *P = new int;

19150.

Represent a structure named student with types and give the advantages of using structure.

Answer»

struct student

{

int regno;

char name [25];

struct

{

short dd;

short mm;

short yy;

}

dob;

char sex;

};

the structure is a group of different types of logically related data referenced by a single name.