Step-by-Step Textbook Solutions for Class 12 Computer Science Chapter 01 Structures and Pointers
Explore reliable textbook solutions for Chapter 01 Structures and Pointers tailored for Class 12 learners. Utilizing these Computer Science answers ensures thorough preparation and strengthens foundational knowledge before final Kerala Board evaluations.
Download Chapter 01 Structures and Pointers Textbook Solutions PDF
View or download the dedicated Chapter 01 Structures and Pointers solution resource below. Engaging with these textbook answers under focused study conditions ensures continuous academic progress and mastery of the 2026-27 curriculum for Computer Science.
One Mark Questions and Answers
Question 1: Name a method used to put logically related elements in one unit.
Answer:
Structure (or class)
Exam Tips:
a) A structure groups related data items, possibly of different types, under one name.
Question 2: ______ keyword is used to specify a structure.
Answer:
struct
Exam Tips:
a) Remember the keyword is written in lower case: struct.
Question 3: State True or False: "A structure can be assigned to another structure only if both the structures are of the same structure type."
Answer:
True
Exam Tips:
a) Assignment between two structure variables works only when both are declared with the same structure tag.
Question 4: 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
Exam Tips:
a) A structure groups related data items under one name; an array is the one that holds items of the same type.
Question 5: Pick the odd one out from the following.
a) int
b) struct
c) char
d) long
Answer:
b) struct
Exam Tips:
a) int, char and long are fundamental data types, whereas struct is a user defined data type.
Question 6: Select the structure member operator.
a) *
b) .
c) ->
d) [ ]
Answer:
b) . (the dot operator)
Exam Tips:
a) The dot operator is used with a structure variable; the arrow operator is used with a pointer to a structure.
Question 7: The address of a computer memory starts at ______
a) 0
b) 1
c) 1024
d) none of these
Answer:
a) 0
Exam Tips:
a) Memory addresses are numbered from 0 onwards.
Question 8: The area used for dynamic memory allocation is called
a) heap
b) stack
c) RAM
d) Hard Disk
Answer:
a) heap
Exam Tips:
a) Heap is the free store for dynamic allocation; the stack holds function call information.
Question 9: Given int *P, x = 35; P = &x; what is the value of *P?
a) 34
b) 35
c) 0
d) none of these
Answer:
b) 35
Exam Tips:
a) *P gives the value stored at the address held by P, which is the value of x.
Question 10: int *P; P holds 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:
d) 2332
int is 4 bytes, so P++ makes P = 2340 + 4 = 2344. Then P - 3 moves back by 3 × 4 = 12 bytes, giving 2344 - 12 = 2332.
Exam Tips:
a) Pointer arithmetic moves in steps of the size of the data type, not by 1 byte.
b) Work it out step by step: after P++ the value is 2344.
Question 11: Dynamic allocation means memory allocation at the time of ______
a) compilation
b) debugging
c) execution
d) programming
Answer:
c) execution
Exam Tips:
a) Static allocation happens at compile time; dynamic allocation happens at run time.
Question 12: The new operator should be matched with a ______
a) pointer
b) reference
c) delete
d) address
Answer:
c) delete
Exam Tips:
a) Every new should have a matching delete to avoid memory leaks.
Question 13: In the declaration void ff(int &, float &); the parameters are passed by ______
a) reference
b) value
c) pointers
d) default
Answer:
a) reference
Exam Tips:
a) The & symbol in a parameter list indicates call by reference.
Question 14: Using ______ the memory location of a variable can be directly accessed and manipulated.
Answer:
Pointers
Exam Tips:
a) A pointer stores the address of a variable, so the variable can be reached directly through it.
Question 15: Anil argued that memory can be allocated as and when required during run time. Do you agree with this opinion? Justify.
Answer:
Yes. Memory can be allocated during run time using the operator new.
Exam Tips:
a) Give the justification (the new operator) along with Yes.
Question 16: Name the unary operator that returns the address of its operand.
Answer:
The & operator (address-of operator)
Exam Tips:
a) Do not confuse & (address of) with * (value at address).
Question 17: Which among the following operators cannot be used with pointers?
a) +
b) -
c) /
d) None of these
Answer:
c) /
Exam Tips:
a) Only addition and subtraction of integers (and increment/decrement) are allowed on pointers; multiplication and division are not.
Question 18: The address of the first byte is known as
a) start
b) Base address
c) int address
d) none of these
Answer:
b) Base address
Exam Tips:
a) The name of an array gives its base address.
Question 19: What are the free store operators?
Answer:
The new and delete operators.
Exam Tips:
a) The free store (heap) is managed with new for allocation and delete for deallocation.
Question 20: Give the syntax of the new operator.
Answer:
pointer_variable = new data_type;
For example: int *P = new int;
Exam Tips:
a) Write the general syntax and one example.
Question 21: What does the following statement mean?int *P = new int[15];
Answer:
It allocates memory for an integer array of 15 elements and stores its starting address in P.
Exam Tips:
a) A square-bracketed size after new means an array is created.
Question 22: The ______ operator reverses the action of the new operator.
Answer:
delete
Exam Tips:
a) delete releases memory that was allocated by new.
Question 23: Which operator is used to access individual elements of a structure or a class while using pointer variables?
a) *
b) .
c) ->
d) None of these
Answer:
c) -> (the arrow operator)
Exam Tips:
a) Use the dot operator with a structure variable and the arrow operator with a pointer to a structure.
Question 24: A pointer is
a) the address of a variable
b) an indication of the variable to be accessed next
c) a variable for storing addresses
d) the datatype of an address variable
Answer:
c) a variable for storing addresses
Exam Tips:
a) A pointer is a variable whose value is a memory address.
Question 25: The expression *test can be said to
a) be a pointer to test
b) refer to the contents of test
c) dereference test
d) refer to the value of the variable pointed to by test
Answer:
d) refer to the value of the variable pointed to by test
Exam Tips:
a) * applied to a pointer is the dereference (indirection) operator and gives the pointed value.
Question 26: The expression double * can be said to
a) be a pointer pointing to variable double
b) refer to contents of double
c) be a pointer to a double type value
d) refer to the value of the variable pointed to by double
Answer:
c) be a pointer to a double type value
Exam Tips:
a) The data type before * tells what type of data the pointer points to.
Question 27: The new operator
a) returns a pointer to a variable
b) creates a variable called new
c) obtains memory for a new variable
d) tells how much memory is available
Answer:
c) obtains memory for a new variable
Exam Tips:
a) new allocates memory from the heap and returns its address.
Question 28: Write a declaration for an array of 8 pointers to float values.
a) float a[]
b) float*[*a][8]
c) float *a[8]
d) float [*a][8]
Answer:
c) float *a[8]
Exam Tips:
a) Read the declaration as: a is an array of 8 elements, each a pointer to float.
Question 29: A pointer to void can hold pointers to ______
a) void
b) int
c) float
d) any data type
Answer:
d) any data type
Exam Tips:
a) A void pointer is a generic pointer and can hold the address of any data type.
Question 30: The contents of two pointers that point to adjacent variables of type float differ by
a) 4
b) 2
c) 1
d) 8
Answer:
a) 4
A float occupies 4 bytes, so adjacent floats are 4 bytes apart.
Exam Tips:
a) The difference equals the size of the data type.
Question 31: In the ______ memory allocation, the amount of memory to be allocated is not known beforehand.
a) Static
b) binding
c) object
d) dynamic
Answer:
d) dynamic
Exam Tips:
a) In static allocation the size is known at compile time.
Question 32: Improper use of new and delete may lead to ______
a) increase of memory
b) memory leaks
c) destruction of memory
d) syntax errors
Answer:
b) memory leaks
Exam Tips:
a) Memory that is allocated but never deleted is lost until the program ends; this is a memory leak.
Question 33: If p is a pointer to the variable x, which of the following statements is correct?
a) p and x may be of different data types
b) if p points to x, then x also points to p
c) the statement x = &p is valid
d) *p will give the value of the variable x
Answer:
d) *p will give the value of the variable x
Exam Tips:
a) p and x must be of compatible types, and pointing is one-way only.
Question 34: Suppose m is a float variable. Another variable ptr stores the address of it, which is 2001. After the operation ptr++, it will point to the location having address ______. Why?
a) 2002
b) 2003
c) 2004
d) 2005
Answer:
d) 2005
Incrementing a pointer adds the size of its data type; a float is 4 bytes, so 2001 + 4 = 2005.
Exam Tips:
a) Always add size of the data type, not 1.
b) Give the reason (the 2001 + 4 step) because the question asks "Why?".
Question 35: State True or False: "Only integers can be added to or subtracted from pointers."
Answer:
True
Exam Tips:
a) You may add or subtract an integer from a pointer, but not another pointer address or a floating point number.
Question 36: Give the syntax for the delete operator.
Answer:
delete pointer_variable;
Exam Tips:
a) Write the keyword delete followed by the pointer name and a semicolon.
Question 37: What does the following statement mean?delete [ ] marks;
Answer:
It deallocates the memory of the array marks.
Exam Tips:
a) The empty square brackets are used to delete a dynamically allocated array.
Question 38: Name the operator that returns the data value stored in the area being pointed to by the pointer.
Answer:
The * operator (value-at-address or dereference operator)
Exam Tips:
a) * with a pointer gives the value; & gives the address.
Question 39: If the name of an array is a pointer to its first element, how do we move to the third element?
Answer:
Array name + 2 gives the address of the third element (for an array a, a + 2, and *(a + 2) gives its value).
Exam Tips:
a) Counting starts from 0, so the third element is at offset 2.
Question 40: What does the following statement mean?int *ptr[10];
Answer:
It declares an array of 10 integer pointers.
Exam Tips:
a) The [10] binds to ptr first, so ptr is an array whose elements are int pointers.
Question 41: State True or False: "It is faster to use an element pointer rather than an index when scanning arrays."
Answer:
True
Exam Tips:
a) Pointer scanning avoids the repeated index calculation.
Question 42: S[0] is not equal to
a) *(S+0)
b) *S
c) *(s)
d) S
Answer:
d) S
Exam Tips:
a) S[0] is the same as *(S+0) and *S; plain S is the address of the first element.
Question 43: Which of the following declarations is valid?
a) int *p = &a;
b) int &p = *a;
c) int &p = &a;
d) int a = &p;
Answer:
a) int *p = &a;
Exam Tips:
a) A pointer declaration uses * and is initialised with an address using &.
Question 44: *p means ______
a) address of p
b) value of p
c) address of the variable pointed to by p
d) value of the variable to which p points
Answer:
d) value of the variable to which p points
Exam Tips:
a) *p dereferences p; &p is the address of p itself.
Question 45: &p means ______
a) address of p
b) value of p
c) address of the variable pointed to by p
d) value of the variable to which p points
Answer:
a) address of p
Exam Tips:
a) & is the address-of operator, so &p is the location where p itself is stored.
Question 46: State True or False: "Only integers can be added to or subtracted from pointers."
Answer:
True
Exam Tips:
a) Adding two pointers is not allowed.
Question 47: Read the following statements:
(i) While defining a structure in C++, the 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) The elements of a structure are 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
Answer:
d) Statements (i) and (iii) are true
Exam Tips:
a) Check each statement separately before choosing the option.
b) Remember that a structure variable name (not the structure tag) is used with the dot operator.
Question 48: 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;
Exam Tips:
a) The structure variable comes first, then the dot, then the member name.
Question 49: Which one of the following is not correct about a pointer?
a) A pointer stores an address
b) A pointer stores the L-value of a variable
c) A pointer points to a memory location
d) A pointer stores the R-value of a variable
Answer:
d) A pointer stores the R-value of a variable
A pointer stores the address (L-value) of a variable, not its value (R-value).
Exam Tips:
a) L-value means address of a variable and R-value means its content.
Question 50: The following are some pointer variable declarations.
(a) float *ptr;
(b) int ptr*;
(c) short *ptr1, *ptr2;
(d) double ptr;
Choose the correct declarations.
a) a and b
b) a and c
c) a and d
d) a only
Answer:
b) a and c
Exam Tips:
a) The * must come before the pointer name, so (b) is wrong; (d) declares an ordinary variable, not a pointer.
Question 51: The address of operator (&) is used for
a) Obtaining the R-value of a variable
b) Obtaining the L-value of a variable
c) Obtaining the content of a variable
d) None of these
Answer:
b) Obtaining the L-value of a variable
Exam Tips:
a) L-value = address; R-value = stored value.
Question 52: Differentiate static and dynamic memory allocation.
Answer:
When the amount of memory to be allocated is known in advance and the memory is allocated during compilation itself, it is called static memory allocation.
When the amount of memory is not known in advance and memory is allocated as and when required during run time, it is called dynamic memory allocation.
Exam Tips:
a) Mention the time of allocation (compile time or run time) for each.
b) Give the keyword used for dynamic allocation (new) for extra clarity.
Question 53: If memory allocated using the dynamic memory allocation operator new is not deallocated using the operator delete, a problem occurs. Name that problem.
Answer:
Memory leak
Exam Tips:
a) The lost memory cannot be reused until the program ends.
Question 54: "There is no chance of memory leak in static memory allocation." Say True or False. Justify.
Answer:
True
In static allocation the operating system (compiler) takes care of allocating and releasing the memory automatically, without any instruction from the user.
Exam Tips:
a) Justify the True/False statement; a bare answer may not get full marks.
Question 55: Write a C++ code segment to declare an integer pointer variable named p and store the address of an integer variable n into it.
Answer:
int *p, n;
p = &n;
Exam Tips:
a) Use & to get the address of n; the pointer must be of type int *.
Question 56: Consider the following code segment in C++. If a is stored at memory location 4020 and the size of int is 4, predict the output.
int *x, a;
x = &a;
cout << x++ << "\n";
cout << ++x;
Answer:
4020
4028
x starts at 4020. x++ prints 4020 and then x becomes 4024. ++x makes it 4028 before printing.
Exam Tips:
a) Post-increment uses the old value first; pre-increment uses the new value.
b) Each step adds 4 because the size of int is 4.
Question 57: Choose the operator which is not associated with a pointer variable.
a) *
b) .
c) &
d) ->
Answer:
b) . (dot operator)
Exam Tips:
a) The dot operator is used with structure variables, not with pointers.
Question 58: The arrow (->) operator is used for accessing
a) a structure element using a structure variable
b) a structure element using a structure name
c) a structure element using a structure pointer variable
d) a structure element using a structure tag
Answer:
c) a structure element using a structure pointer variable
Exam Tips:
a) p->member is equivalent to (*p).member.
Question 59: Write a C++ statement to declare an array, using a character pointer variable, which can store the names of 60 students in a class.
Answer:
char *name[60];
Exam Tips:
a) This is an array of 60 character pointers, each pointing to one name.
Question 60: Read the following statements.
(i) A structure which contains another structure is called a self referential structure.
(ii) A structure which contains a pointer to another structure is called a self referential structure.
(iii) A structure which contains another structure is called a nested structure.
(iv) A structure which contains a pointer to the same structure is called a self referential structure.
Now choose the correct option from the following
a) Statements (i) and (ii) are true
b) Statements (i) and (iii) are correct
c) Statements (ii) and (iii) are correct
d) Statements (iii) and (iv) are correct
Answer:
d) Statements (iii) and (iv) are correct
Exam Tips:
a) Nested = structure inside a structure; self referential = pointer to its own type.
Question 61: A structure is a ______ data type. Fill in the blank by choosing the correct option.
a) Fundamental
b) Derived
c) User defined
d) Built in
Answer:
c) User defined
Exam Tips:
a) The programmer defines a structure, so it is a user defined data type.
Question 62: Write the declaration statement of a student structure variable named s which is initialised with admission number 19, name as "Aysha" and mark as 75.
Answer:
student s = {19, "Aysha", 75};
Exam Tips:
a) Values in braces must follow the order of the members in the structure.
Question 63: "The dot (.) operator cannot be used for accessing a structure member by using a structure pointer variable." Say True or False. Justify your answer.
Answer:
False. With a structure pointer variable the arrow (->) operator is the one normally used to access a member.
Exam Tips:
a) A pointer p can also be used as (*p).member, so the dot operator can be used after dereferencing; but the usual operator is ->.
Two Mark Questions and Answers
Question 64: Write C++ statements for the following.
1. To declare an integer pointer named x using the new operator.
2. To initialise the integer pointer x with the value 5.
3. To declare a dynamic array of ten integers named x.
Answer:
1. int *x = new int;
2. int *x = new int(5);
3. int *x = new int[10];
Exam Tips:
a) Round brackets after the type give an initial value; square brackets give an array.
b) Leave a space between new and the data type.
Question 65: Consider the following C++ program code to store the address of an integer variable a into a pointer variable p.
int a = 5, *p;
p = a;
cout << p;
Identify the error in the above program segment and correct it.
Answer:
The statement p = a; is the error, because p is an integer pointer and can store only an address. The correct statement is p = &a;
Exam Tips:
a) Pointers store addresses, so use the & operator with the variable.
b) Rewrite the corrected code line clearly.
Question 66: Correct the program code given below.
int a = 5;
float *p;
p = &a;
cout << p;
Answer:
The pointer type does not match the variable type. Either change float *p; to int *p;
or change int a = 5; to float a = 5;
Exam Tips:
a) A pointer must be of the same data type as the variable whose address it stores.
Question 67: Calculate the memory requirement for the following structure variable s1. [Consider the size of int = 4, char = 1 and float = 4]
struct student
{
int mo;
char name[25];
float height;
} s1;
Answer:
| Member | Bytes used |
|---|---|
| mo | 4 |
| name | 25 × 1 = 25 |
| height | 4 |
| Total | 33 |
The structure variable s1 uses 33 bytes of memory.
Exam Tips:
a) Add the sizes of all members; for an array multiply its size by the number of elements.
b) Show the working in a table or line by line.
Question 68: Consider the following array initialisation: int ar[5] = {-2, -4, -6, 2, 4}; If the first element of the array is stored at 2050 and the size of int is 4, find the output of the following.
1. cout << *ar + *(ar+3);
2. cout << ar + *(ar+4);
Answer:
1. *ar = -2 and *(ar + 3) = 2 (the fourth element).
So *ar + *(ar + 3) = -2 + 2 = 0. The output is 0.
2. ar = 2050 (the starting address).
*(ar + 4) = *(2050 + 4 × 4) = *(2066) = 4 (the fifth element).
So ar + *(ar + 4) = ar + 4 = 2050 + 4 × 4 = 2066. The output is the address 2066.
Exam Tips:
a) Adding an integer to a pointer scales by the size of the data type.
b) Separate the value (*ar) from the address (ar) in your working.
Question 69: Match the following.
| A | B |
|---|---|
| a) dereference operator | i) new |
| b) address of operator | ii) . |
| c) used for accessing structure member | iii) * |
| d) dynamic memory allocation operator | iv) & |
Answer:
a - iii
b - iv
c - ii
d - i
Exam Tips:
a) Dereference = *, address of = &, member access = dot, allocation = new.
Question 70: Complete the following table which differentiates array and structure.
| Array | Structure |
|---|---|
| A derived data type | ______ |
| ______ | Collection of different types of data |
Answer:
| Array | Structure |
|---|---|
| A derived data type | A user defined data type |
| Collection of the same type of data | Collection of different types of data |
Exam Tips:
a) An array holds data of one type; a structure can hold different types.
Question 71: Identify the errors in the following code fragment and correct them.
struct sample
{
int x;
float y;
} S1, S2;
void main()
{
struct test
{
int a;
float b;
} T1, T2;
T1 = T2;
T1 = S1;
}
Answer:
The assignment T1 = S1; is not correct. T1 is a variable of type test and S1 is a variable of type sample, so one cannot be assigned to the other. (T1 = T2; is correct because both are of the same type.)
Exam Tips:
a) Structure variables can be assigned only when they are of the same structure type.
Question 72: When a C++ program is executed, the primary memory allocated for it is organised in a particular manner to deal with run time memory allocation, function calls, variables, etc. Show a diagrammatic representation of it with a brief explanation.
Answer:
After compilation, C++ creates four distinct regions of memory for distinct purposes.
The first area (1) stores the compiled code of the program.
The second area (2) stores the global variables of the program; they remain in memory until the program ends.
The third region (3), the stack, holds return addresses of function calls, the arguments passed to functions, etc.
The last region (4), the heap, is used for dynamic allocation.
Exam Tips:
a) Draw the four labelled boxes and number them in the same way as in the explanation.
b) Write one line about each region.
c) Mention that the heap is used for dynamic memory allocation.
Question 73: Analyse the following C++ statements and predict the output.
int k = 4;
int *p;
p = &k;
cout << k;
cout << *p;
cout << *p++;
cout << *(&k);
Answer:
The four outputs are 4, 4, 4, 4 (printed together as 4444).k is 4; *p is the value at the address of k, which is 4; *p++ first gives the value 4 and then moves the pointer; *(&k) is again the value of k, which is 4.
Exam Tips:
a) Post-increment returns the old value before moving the pointer.
b) cout prints values one after another without spaces unless you add them.
Question 74: A boy wrote a C++ program that uses several pointer variables, out of which some are used for dynamic allocation. He did not use the delete operator anywhere in the program. While running the program, the computer got stuck after some time. Predict the reason for this situation in connection with the program code.
Answer:
The situation is called a memory leak. Memory allocated using new should be deallocated using delete. If a function forgets to release memory that was allocated with new, it consumes some memory every time it runs. A part of the memory is thus lost with every execution and this affects the system adversely.
Exam Tips:
a) Name the problem (memory leak) first, then explain how it happens.
b) Mention the remedy: use delete for every new.
Question 75: Is there any difference between a structure and an array? Explain.
Answer:
Yes. An array can hold multiple elements of the same data type, whereas a structure can hold multiple elements of different data types.
Exam Tips:
a) Mention same type versus different types, and give an example if time permits.
Question 76: Write a C++ structure definition to store the student details given below.
1. Admission number
2. Name
3. Marks in six subjects
Answer:
struct student
{
int Admno;
char name[30];
int mark[6];
};
Exam Tips:
a) Use the keyword struct in lower case and end the definition with a semicolon.
b) Marks in six subjects need an array of size 6.
Question 77: Observe the following layout of data.
| Acc No | Name of Account holder | Last transaction date | Balance Amount | ||
|---|---|---|---|---|---|
| Day | Month | Year |
1. Name the data type in C++ used to represent the above data format.
2. Write the definition for implementing the above layout.
Answer:
1. Structure (a nested structure)
2. struct Account
{
int accno;
char name[30];
struct lastdate
{
int day;
int month;
int year;
} tdate;
float balanceamt;
};
Exam Tips:
a) The date is a group inside the main record, so use a structure inside a structure.
Question 78: Consider the following code segment.
struct student
{
int rollno;
char name[20];
struct date
{
int day;
int month;
int year;
} birthday;
char batch[30];
int score;
};
Write valid statements in C++ to accept the name and date of birth of a student.
Answer:
Assuming S1 is a variable of type student:gets(S1.name);
S1.birthday.day = 25;
S1.birthday.month = 5;
S1.birthday.year = 1991;
Exam Tips:
a) Use the dot operator twice to reach members of the inner structure (S1.birthday.day).
b) Declare the structure variable first: student S1;
Question 79: Why do we need structure variables once a structure is defined in a program?
Answer:
A structure definition is merely a data type definition and no memory is allocated when it is defined. To handle data, memory locations are needed, and memory is allocated only when variables are declared. Hence structure variables are essential for handling structured data in programs.
Exam Tips:
a) Remember: type definition = no memory; variable declaration = memory is allocated.
Question 80: With an example, explain how structures can be initialised.
Answer:
student stud = {"Athul", 17, 101, "XII Science"};
The above statement initialises the structure variable stud of type student, whose data members are name, age, roll no and batch, with the given values in order.
Exam Tips:
a) Values in the braces are assigned to the members in the order of their declaration.
Question 81: Can we declare a structure within another structure? Explain.
Answer:
Yes. We can declare a structure as a member of another structure. This is known as a nested structure.
Exam Tips:
a) Give a small example, such as a date structure inside an employee structure.
Question 82: What does the following statement mean?S.dob.month = 10;
Answer:
It accesses an element of a nested structure. S is a structure variable that contains another structure variable dob, and month is a member of the inner structure variable dob. This statement assigns the value 10 to the member month.
Exam Tips:
a) Read the statement from left to right: outer variable, inner structure, member.
Question 83: Thomas says that the name of an array is a pointer by default. Do you agree with him? Justify.
Answer:
Yes. C++ takes the array name as the address of its first element. That is, the name of an array is actually a pointer pointing to the first element of the array.
Exam Tips:
a) Add that the array name is a constant pointer, so arr++ is not allowed.
Question 84: Distinguish betweenint *ptr = new int(5);int *ptr = new int[5];
Answer:
The first statement allocates memory for one integer for ptr and initialises it with the value 5.
The second statement allocates memory for 5 contiguous integers (an array of 5 integers) and stores the beginning address in the pointer ptr.
Exam Tips:
a) Round brackets give an initial value, square brackets give an array size.
Question 85: Give the syntax to declare an integer 2D array dynamically.
Answer:
int *ptr = new int[m * n];
where m and n are the numbers of rows and columns.
Exam Tips:
a) The m × n elements are allocated as one block and accessed using the pointer.
Question 86: The array of character pointers is generally preferred over a two dimensional array of characters. Justify.
Answer:
There are two reasons.
1. An array of pointers makes more efficient use of memory because it uses fewer bytes to store the strings.
2. An array of pointers makes the manipulation of the strings much easier. The positions of the strings can be exchanged by swapping the pointers, without moving the strings in memory.
Exam Tips:
a) Give both points: saving of memory and ease of rearranging strings.
Question 87: Predict the errors in the following code fragments in C++.
1. float f = 1.42;
float *a;
a = f;
2. int *p, *q;
p = q + 1;
Answer:
1. a = f; is wrong because a pointer must be assigned an address. The correct statement is a = &f;
2. No value (address) has been assigned to q (and p) before they are used, so q + 1 is meaningless.
Exam Tips:
a) A pointer must always hold a valid address before it is used.
Question 88: Define a structure in C++ to store book details such as book id, book name, price and author name.
Answer:
A structure is a group of different types of logically related data referenced by a single name.struct book
{
int book_id;
char book_name[40];
float price;
char author_name[40];
};
Exam Tips:
a) Choose suitable data types: int for id, char arrays for names, float for price.
Question 89: Complete the following structure definition to store student details with appropriate values. The details are roll number, name and height.______ struct students
{
______ mo;
char ______ ;
______ height;
};
Answer:
struct students
{
short rno;
char name[25];
float height;
};
Exam Tips:
a) Pick data types by the nature of the data: short or int for roll number, char array for name, float for height.
Question 90: Correct the following structure definition to represent an employee with employee code, employee name and salary.Employee struct
{
ecode int;
char name[25];
salary double;
}
Answer:
struct Employee
{
int ecode;
char name[25];
double salary;
};
Exam Tips:
a) The keyword struct comes first, then the tag; the data type comes before each member name.
Question 91: Consider the array declaration. Assume that the first element of the array is stored at location 2020.int a[] = {2, 5, 8, 9, 4}, *p1, *p2;
p1 = a;
p2 = &a[0];
cout << p1 << "\t" << p2;
Predict the output and justify.
Answer:
p1 = a means the array name is the starting address of the array, so p1 = 2020.p2 = &a[0] is the address of the first element, so p2 = 2020.
Hence the output is 2020 2020.
Exam Tips:
a) Name of array and &a[0] both give the base address.
Three Mark Questions and Answers
Question 92: Explain the type of structure defined below and calculate the number of bytes required to store the structure variable s1. [Consider the size of int as 4 bytes and char as 1 byte]struct student
{
int mo, mark;
char name[25];
struct date
{
int dd, mm, yy;
} doj;
} s1;
Answer:
A structure that contains another structure is called a nested structure.
| Member | Bytes used |
|---|---|
| mo | 4 |
| mark | 4 |
| name | 25 × 1 = 25 |
| dd | 4 |
| mm | 4 |
| yy | 4 |
| Total | 45 |
The inner structure doj uses 12 bytes and s1 uses a total of 45 bytes of memory.
Exam Tips:
a) Total bytes = sum of all members, including the members of the inner structure.
b) State the type (nested structure) clearly.
Question 93: Define a structure to represent employee details. The details are employee code, employee name, date of joining and place of the employee.
Answer:
struct employee
{
int empcode;
char name[40];
struct date
{
int day;
int month;
int year;
} doj;
char place[40];
};
Exam Tips:
a) Date of joining has three parts, so use a nested structure.
Question 94: "Self referential structure can be used for implementing a linked list." Justify the statement.
Answer:
A structure that contains an element which is a pointer to the same structure is called a self referential structure.
Example:struct date
{
int dd, mm, yyyy;
date *ptr;
};
Because each node holds a pointer to the next node of the same type, self referential structures can be used for implementing a linked list.
Exam Tips:
a) Give the definition and a small example with a pointer to its own type.
Question 95: Write a program in C++ to copy one string to another without using the strcpy() function.
Answer:
#include <iostream>
using namespace std;
int main()
{
char str[] = "computer";
char dest[20];
char *sptr = str, *dptr = dest;
while (*sptr != '\0')
{
*dptr = *sptr;
sptr++;
dptr++;
}
*dptr = '\0';
cout << str << endl;
cout << dest << endl;
return 0;
}
The loop copies the characters one by one from str to dest and finally adds the null character.
Exam Tips:
a) Do not forget to put the null character (\0) at the end of the copied string.
b) Use two pointers, one for each string, and move both in the loop.
Question 96: Define a structure in C++ to store the details of students such as admission number, name and address. The address contains house number, street name and city name.
Answer:
A structure is a group of different types of logically related data referenced by a single name.struct student
{
int adm_no;
char name[40];
struct
{
int house_no;
char street_name[40];
char city_name[40];
} address;
};
Exam Tips:
a) The address is a nested structure inside student.
Question 97: "A structure variable can be declared along with the structure definition." Justify this statement with an example.
Answer:
Yes, a structure variable can be declared along with the structure definition itself.
Syntax:struct struct_name
{
data members;
} structure_variables;
Example:struct date
{
int dd;
int mm;
int yyyy;
} d1, d2, d3;
Exam Tips:
a) Variables are listed between the closing brace and the semicolon.
Question 98: Identify and correct the error in the following code fragment.struct first
{
int a;
float b;
} S1;
struct second
{
int a;
float b;
} S2;
S1 = S2;
Answer:
The assignment S1 = S2; is not right, because S1 and S2 are variables of different structure types. C++ does not permit assignment between variables of different structure types, even though their members look the same.
Exam Tips:
a) Both variables must be declared with the same structure tag for assignment to work.
Question 99: Write structure definitions for structures containing the following.
1. Book number, book name, price
2. Item number, item name, price, monthly sales for the last 4 months
Answer:
1. struct book
{
long bookno;
float price;
char bookname[50];
};
2. struct item
{
int itemno;
char itemname[50];
float price;
int sale[4];
};
Exam Tips:
a) Four monthly sales values need an array of size 4.
Question 100: Assume that in a city, two football matches are going to be held. The coordinators have decided to sell the tickets in two different styles. For the first match, the tickets will be sold one month in advance, but for the second one, tickets will be available at the stadium on the very day of the match.
1. Correlate this situation with the memory allocation techniques in C++.
2. Compare the merits and demerits of the two in relation to the given context.
Answer:
1. Static memory allocation and dynamic memory allocation.
2. Every piece of data and every instruction being executed must be allocated some area in main memory. This can be done in two ways.
Static memory allocation: when the amount of memory to be allocated is known in advance and the memory is allocated during compilation itself, it is called static memory allocation. It is like selling tickets in advance for the first match: the number is fixed beforehand, so nothing is wasted at the last moment, but the quantity cannot be changed later.
Dynamic memory allocation: when the amount of memory is not known in advance and it is allocated as and when required during run time, it is called dynamic memory allocation. It is like selling tickets on the day of the second match: the number is decided as demand arises, so the allocation is flexible, but it needs to be managed carefully.
Exam Tips:
a) Link the first match to static allocation and the second to dynamic allocation.
b) Give at least one advantage and one disadvantage of each method.
Question 101: When a C++ program is compiled, the compiler allocates 20 bytes of memory, and when the same program is executed, 10 more bytes of memory are allocated.
1. How do you account for these two types of memory allocations?
2. Name the operator used for the second type of memory allocation and also write its syntax.
Answer:
1. Static memory allocation (at compile time) and dynamic memory allocation (at run time).
2. The new operator is used for dynamic memory allocation.
Syntax: pointer_variable = new datatype;
Example: int *ptr = new int;
Exam Tips:
a) Static allocation happens during compilation and dynamic allocation during execution.
Question 102: Justify the following statements.
1. In C++, the delete operator performs the reverse action of the new operator.
2. If arr is the name of an array, then arr++ is not a valid statement.
3. If k is a long variable with address 1001 and its address is stored in a pointer variable p, then p + 1 will point to the location with address 1005.
Answer:
1. Both new and delete are used for dynamic allocation and deallocation of memory. Memory allocated at run time using new is released using delete, so delete reverses the action of new.
2. arr++ is not valid because the base address of an array cannot be changed; the array name gives the base address of the array.
3. A pointer variable holds the address of the memory location where data is stored. Incrementing the pointer adds the size of its data type. A long takes 4 bytes here, so p + 1 points to 1001 + 4 = 1005.
Exam Tips:
a) Justify each statement separately and number your points.
b) Pointer increments depend on the size of the data type.
Question 103: Discuss the similarities and differences of a structure as compared to an array and a class.
Answer:
Structure compared with array:
| Structure | Array |
|---|---|
| 1. A user defined data type | 1. A predefined (derived) data type |
| 2. A collection of different types of logically related data under one name | 2. A collection of data elements of the same data type having a common name |
| 3. Elements are referenced using the dot operator (.) | 3. Elements are referenced using subscripts (position value) |
| 4. When an element of a structure becomes another structure, nested and complex structures are formed | 4. When an element of an array becomes another array, multidimensional arrays are formed |
| 5. A structure can contain an array as its elements | 5. An array of structures can be formed |
Structure compared with class: both are user defined data types. A structure is a collection of related data items, whereas a class is a collection of data and functions.
Exam Tips:
a) Draw a two-column table to compare points one by one.
b) Mention the common point (both group related data under one name) as well as the differences.
Question 104: Consider the following code fragment.char nam[] = "COMPUTER";
for (int i = 0; nam[i] != '\0'; i++)
cout << nam[i];
Rewrite the above code to get the same output using a character pointer variable.
Answer:
char nam[] = "COMPUTER";
char *P;
for (P = nam; *P != '\0'; P++)
cout << *P;
Exam Tips:
a) The pointer starts at the array name (the base address) and moves till it finds the null character.
Question 105: Match the following.
| A | B |
|---|---|
| 1) The arrow operator (->) | a) Self referential structure |
| 2) Deallocation operator | b) Object pointer |
| 3) Starting address of a memory location | c) delete |
| 4) A member refers to the structure itself | d) Base address |
Answer:
1 - b
2 - c
3 - d
4 - a
Exam Tips:
a) The arrow operator is used with an object (structure) pointer.
Question 106: How is dynamic memory allocation different from static memory allocation?
Answer:
In static memory allocation, the amount of memory to be allocated is predicted and known in advance. The memory is allocated during compilation itself. All normally declared variables are allocated memory statically.
In dynamic memory allocation, the amount of memory to be allocated is not known beforehand. It is allocated during run time as and when required, using the new operator.
Objects allocated memory statically live for as long as their scope allows, as decided by the compiler. Objects allocated memory dynamically live as long as the programmer decides; they remain in memory until the programmer explicitly deallocates the memory.
Exam Tips:
a) Compare on three points: time of allocation, knowledge of size, and lifetime of objects.
Five Mark Questions and Answers
Question 107: Read the following structure definition and answer the questions.struct Book
{
int book_no;
char bk_name[20];
struct
{
short dd;
short mm;
short yy;
} dt_of_purchase;
float price;
};
a) Write a C++ statement to declare a variable to refer to the details of a book. What is the memory requirement of this variable? Justify your answer.
b) Write a C++ statement to initialise this variable with the details of your Computer Science textbook.
c) Write C++ statement(s) to display the details of the book.
d) "The missing structure tag in the inner structure does not cause any error." State whether this is true or false. Give the reason.
Answer:
a) Book b;
| Member | Bytes used |
|---|---|
| book_no | 4 |
| bk_name | 20 |
| dt_of_purchase | 2 + 2 + 2 = 6 |
| price | 4 |
| Total | 34 |
A total of 34 bytes is allocated to the variable b.
b)
Book b = {101, "Computer Science", {22, 9, 2015}, 127};c)
#include <iostream>
using namespace std;
struct Book
{
int book_no;
char bk_name[20];
struct
{
short dd, mm, yy;
} dt_of_purchase;
float price;
};
int main()
{
Book b = {101, "Computer Science", {22, 9, 2015}, 127};
cout << "Book No\t: " << b.book_no << endl;
cout << "Book Name\t: " << b.bk_name << endl;
cout << "Date of Purchase\t: " << b.dt_of_purchase.dd << "/" << b.dt_of_purchase.mm << "/" << b.dt_of_purchase.yy << endl;
cout << "Price\t: " << b.price;
return 0;
}d) True. There is no need to give a structure tag to the inner structure because its variable (dt_of_purchase) is declared inside the structure itself.
Exam Tips:
a) Add up the member sizes carefully for part (a); the inner structure has three short values (2 bytes each).
b) Use the dot operator twice to display members of the inner structure.
c) For part (d), the inner structure is used only through its variable name, so a tag is not needed.
Question 108: You are given an assignment by the teacher to write a C++ program that accepts the age of n people who attended a medical camp. The value of n is not known beforehand and is to be accepted at the time of running the program. The program should print the average age as the final output. Develop the code.
Answer:
#include <iostream>
using namespace std;
int main()
{
int n, tot = 0;
float avg;
cout << "Enter the number of people: ";
cin >> n;
int *p = new int[n];
cout << "Enter the ages of the people: ";
for (int i = 0; i < n; i++)
{
cin >> *(p + i);
tot = tot + *(p + i);
}
avg = (float)tot / n;
cout << "Average age = " << avg;
delete [] p;
return 0;
}
Exam Tips:
a) Because n is known only at run time, allocate the array with new.
b) Release the memory with delete [] at the end.
c) Convert tot to float before dividing, otherwise the decimal part of the average is lost.
Question 109: How are the following related?
1. Structure and array
2. Structure and class
Answer:
1. Structure and array:
Both are derived (compound) data types in C++. A structure is a collection of related data items that can be of different data types, while an array is a collection of elements of the same data type. Thus both arrays and structures allow several values to be treated together as a single data object.
2. Structure and class:
Both are user defined data types. A structure is a collection of related data items, while a class is a collection of data and functions. Hence a structure plus related functions forms a class.
Exam Tips:
a) Mention a similarity and a difference for each pair.
Free study material for Computer Science
Kerala Board Solutions for Class 12 Computer Science Chapter 01 Structures and Pointers
Textbook Solutions for Class 12 Computer Science Chapter 01 Structures and Pointers
Review comprehensive exercise answers for Class 12 Computer Science Chapter 01 Structures and Pointers. Fully updated to match current Kerala Board syllabus guidelines, these textbook solutions help students verify their work and maintain accurate study notes.
Mastering Theoretical and Practical Questions
Each solution includes detailed reasoning to foster genuine comprehension of Chapter 01 Structures and Pointers concepts. Reviewing these step-by-step breakdowns allows learners to master both analytical and descriptive questions expected in school evaluations.
Effective Self-Study and Homework Assistance
Frequent review of these structured answers builds strong analytical capabilities and response efficiency. Maximize your academic readiness by combining these textbook solutions with our curated study materials and mock evaluations for Class 12 Computer Science.
FAQs
The complete and updated Kerala Plus Two Computer Science Chapter 1 Structures and Pointers Questions and Answers is available for free on StudiesToday.com. These solutions for Class 12 Computer Science are as per latest Kerala Board curriculum.
Yes, our experts have revised the Kerala Plus Two Computer Science Chapter 1 Structures and Pointers Questions and Answers as per 2026 exam pattern. All textbook exercises have been solved and have added explanation about how the Computer Science concepts are applied in case-study and assertion-reasoning questions.
Toppers recommend using Kerala Board language because Kerala Board marking schemes are strictly based on textbook definitions. Our Kerala Plus Two Computer Science Chapter 1 Structures and Pointers Questions and Answers will help students to get full marks in the theory paper.
Yes, we provide bilingual support for Class 12 Computer Science. You can access Kerala Plus Two Computer Science Chapter 1 Structures and Pointers Questions and Answers in both English and Hindi medium.
Yes, you can download the entire Kerala Plus Two Computer Science Chapter 1 Structures and Pointers Questions and Answers in printable PDF format for offline study on any device.