Class XII | Assignment 2 ( C Structure)

STRUCTURE (Submit after Mid Term , 15 Ashad 2083)

A) MCQ

1. What is the size of an int data type
a. 4 Bytes
b. 2 Bytes
c. Depends on the system/compiler
d. Cannot be determined

2. The format identifier “%i” is also used for _____ data type.
a. Char
b. int
c. float
d. double

3. Is it possible to run program without main () function?
a. Yes
b. No
c. Yes but wrong output
d. sometime

4. How many main () function we can have in our project?
a. 1
b. 2
c. No Limit
d. Depends on compiler

5. Register variable is stored in ……..
a. in CPU
b. cache memory
c. main memory
d. secondary memory

6. Automatic variable are stored in
a. Stack
b. data segment
c. register
d. heap

7. Union differs from structure in the following way.
a. All members are used at a time
b. Only one member can be used at a time
c. Union cannot have more members
d. Union initialized all members as structure.

8. The default parameter passing mechanism is
a. Call by value
b. call by reference
c. call by value result
d. None

9. Size of a union is determined by size of the
a. First member in the union
b. Last member in the union
c. Sum of the sizes of all members
d. Biggest member in the union

Short Q/A

1. What is structure (Explain with syntax and example)? Write the advantages of using structure. [2074/76]
2. What is union? What are the advantages of using union?
3. Differentiate between structure and union with example and syntax. [2073 set c]
4. Explain how the value of structure can be accessed.
5. Differentiate between array and structure.
6. Differentiate between structure and union.
7. What is nested structure? Explain with example.

Program
1. Write a program to input the 5 employees’ name and salary using structure and display the record in proper
format. [2074 B]
2. Write a program to sort an arry of n elements in descending order.
3. Write a program to enter “name”, “roll_no” and “marks” of 10 students and sort them in descending order
of mark and display .
4. Write a program to enter the marks of 5 students in using a structure named Marks having elements roll no.,
name, Nepali_marks, maths_marks and computer_marks and then display the percentage of each student.
5. Write any C program using union.
6. Write a program to store name and age of 20 students. Sort these data according mark in ascending order of
age and display them.
7. Write a C program to input emp_id, emp_name, emp_salary of 10 employees using structure and dispay the
emp_id, emp_name and emp_salary of the employee receiging a highest and lowest salary.
8. Write a C program that reads different names and address into the computer and rearrange the names into
alphabetical order using the structure variable.

Leave a Comment