# 1st PUC Computer Science Question Bank Chapter 14 Structures

## Karnataka 1st PUC Computer Science Question Bank Chapter 14 Structures

### 1st PUC Computer Science Structures One Mark Questions and Answers

Question 1.
Define structure.
A structure is a collection of variables which can be of the same or different types.

Question 2.
What is the use of structures?
Structures can be used to handle a group of logically related data items like register number, student name, subject marks, etc., under a single name.

a

Question 3.
What is the purpose of a struct keyword?
It is the reserved or keyword, used in structure definition.

Question 4.
What is a structure tag?
Structure tag is a name given by the programmer and used to identify the structure during future re-definitions.

Question 5.
What is a structure template?
The list of all the structure members is called a template.

Question 6.
What purpose does structure definition serve?
The structure definition acts as a blueprint for the creation of variables.

Question 7.
How is a member of a structure accessed?
The member of the structure is accessed by using the dot (.) operator.

Question 8.
Write the declaration syntax for a structure variable.
The general syntax for declaration of structure variable is Structurename variable;

Question 9.
Define nested structures.
When a structure is defined as a member of another structure the embedded structure is called a nested structure.

Question 10.
What is an array of structures?
Array of structure is a collection of array elements in which, each element of the array is a structure.

### 1st PUC Computer Science Structures Two/Three Marks Questions and Answers

Question 1.
Give the difference between array and structure.
An array is a collection of similar data elements under a single name whereas structure is a collection of dissimilar data elements under a single name.

Question 2.
Give the declaration of structure.
struct <structure-tag>
{
<data_type> <member variablel>
<data_type> < member variable2> list of members
<data_type> < member variable3>
} <structure-variable-name 1>, <structure-variable-name2>;

Question 3.
Write the structure definition to store name of the student, register number, class.
struct student
{
int SP regno;
char name[50];
char class[6];
};

Question 4.
How is a structure initialized? Give an example.
Initialization is done at the time of declaration of a variable. For example
Student S2 = {100,17,”Aniket”,92};

Question 5.
How are structure members accessed? Give an example.
The accessing of data of the members is done by using the following format:
structure variable.member name
for example cin>>s1.rollno>>s1.age>>s1.name>>s1.marks;

Question 6.
How is an array of structure declared? Give an example.
The array of structure is a collection of array elements in which each element is a structure in the array.
For example,
struct student
{
int regno;
char name [50];
char class [6];
} s[100];

### 1st PUC Computer Science Structures Five Marks Questions and Answers

Question 1.
Explain the elements of structure definition. Give an example.
struct <structure-tag>
{
<data_type> <member variable 1>
<data_type> < member variable2> list of members
<data_type> < member variable3>
} <structure-varable-namel>, <structure-varable-name2>;
1. struct:
It is the reserved or keyword used in structure definition.

2. <structure-tag>:
It is the name given by the programmer and used to identity the structure in future re-definitions. They are used to declare structure variables.

3. <data-type>:
Any valid data type in ‘C’.

4. < member variable 1…4>:
are names of the variables.

5. <structure-variable-name 1 ,.2>:
It is used to access the members of the structure.
Example:
struct student
{
int SP regno;
char name[20];
char class[5];
char combination[4];
float fees;
} st1, st2, st3;

Question 2.
Write the different methods of structure initialization.
A struct variable can be initialized, like any other data variables in C++, at the time it is declared. We could use:
struct student {
char name[20];
int regno;
float fees;
} s1 = {“ram”, 25,24000.50};
or
student s1 = {“ram”, 25,24000.50};

Question 3.
Explain the nesting of structures with an example.
A structure defined as a member of another structure is called a nested structure.
Example of a nested structure:
struct date
{
int  day;
int  month;
int  year;
};
struct student
{
int regno;
char name[20];
char class[10];
struct date dob;
}st1, st2, st3;
In the above example, st1, st2, and st3 are the structure variable of type student and date is a structure definition. The members of student structure are regno, is an integer data type, name and class which are char type and dob admission date are date structure type variable members. The dob and admission date are and the structure variable who are members of another structure.

Question 4.
Explain the use of an array of structures with an example.
The use of arrays in the place of normal structure variables refers to the array of structure, i.e., if we want to store different values of regno, name, class, etc., for 100 students then we need a structure and 100 different structure variable names. The creation of 100 different variables can be avoided using an array.
For example; if we use thenormal method of storing values for student structure type then we need 10 structure variables with unique name.
struct student
{
int regno;
char name[20];
char class[5];
char combination[4];
float fees;
} st1, st2, st3, st4, st5, …………………st100;
This waste of usage can be avoided by declaring an array variable in that place in the following manner
Example:
struct student
{
int regno;
char name [20];
char class[5];
charcombination[4];
float fees;
} st[100]; → st[100] is array variable

a