You are on page 1of 4

Assignment – 10

Deadline: 20th Feb, 2021

Q1. Define a structure having the following fields – Call it a student


type structure – struct student
Name: Character array of 100 length
Roll Number: Integer
Department Number: Integer
Address: Character array of 100 length
Hostel No: Integer

Create the following functions -


a. input_student_from_user(struct student *st);
It will ask for values from the user and assign to the respective fields
of the structure variable.

b. print_student(struct student * st);


It will print the fields of the struct student type object in a formatted
fashion.
printf(“---------------------------------”);
…..
printf(“---------------------------------”);

Write a main function to show the operation of the user defined


functions.

c. Create some student variables and assign values manually during


declaration also. Use the print_student() function to print them.
Q2. Searching over students sequential search

a. Declare an array of student type of size 10;


struct student student_db[10];

b. Initialize all the values in the program itself. Write a function to


initialize the array of students.
initialize(struct student st_db*, int num_student);

c. Write a function
int sequential_search(struct student st_db *, int num_stduent, int
roll_no);

The function will go through the full array, and try to check if the provided
roll_no is present in the array or not. If yes returns the index of the array.
Otherwise returns -1.

Use simple sequential search strategy for searching. Write a main


function to show its operation.

Q3. Implementation of Join operation:


Create a structure for storing hostel information -
Hostel number;
Hostel name;
Number of rooms; int
Mesh_type; int veg / nonveg
#define VEG 0
#define NON_VEG 1
#define MIXED 2

int main(){

int mesh_type = 0;

}
struct hostel {

};
Create array of hostels – having three members. – SHR, BHR, MHR …
Fill the information appropriately.

Write a function
print_stduent_by_hostel_name(
struct student *st_db,
int num_students,
struct hostel *hs-db,
int num_hostel,
char *hostel_name);
– which will print all the names of the stduents who resides in the Hostel
hostel_name.
Write a function
print_students_who_are_vegeterian(
struct student *st_db,
int num_students,
struct hostel *hs-db,
int num_hostel,
)

- print the names of the student who stays in a hostel whose mesh type
is VEG.

table 1 for student


table 2 for hostel

Use the same structure of students and the database created in the
previous questions.

You might also like