C-Structures and Unions-And Functions 10
C-Structures and Unions-And Functions 10
#1 Structures
Write programs to --
* 1. Create a structure Student with data members rollno, name, surname. Now in main(), create
and initialize variable of structure Student and print it on screen.
* 2. Create a structure Student with data members rollno, name, surname. Now in main(), create
array of 4 Student structures, read it from user and print it on screen in tabular format.
* 3. In above Q.1, add four more members – m1, m2, total, percentage & grade. Now in main(),
create a variable of Student structure, read its rollno, name, surname, m1 & m2 members
from user. Now compute total, percentage & grade. Print this Student structure on screen.
* 4. In above Q.3, in main(), create an array of 4 Student structure; read rollno, name, surname,
m1 & m2 members from user for this array. Now compute total, percentage & grade for all the
Student elements in the array. Then print this array in tabular format on screen.
#2 Structures and functions
* 5. Create structure Employee with members eno, ename and bsal. Create a function
readEmployee() to read the Employee structure from user. Also create a function
printEmployee() to print the Employee structure on screen.
Now, in main(),
1. create a variable of Empoyee structure; read it using readEmployee() function; and print it
using printEmployee() function.
2. create an array of 4 Employee structures; read it using readEmployee() function; and print
it using printEmployee() function.
* 6. In above Q.5, add more members to Employee structure – da, hra and net_sal. Therefore, you
need to update the printEmployee() function, so update it.
Now, create one more function compute_perks() that takes one Employee structure as
parameter; computes da,hra & net_sal; and returns the computed structure.
1. create a variable of Empoyee structure; read it using readEmployee() function;
compute other perks using compute_perks() function and print it using printEmployee()
function.
2. create an array of 4 Employee structures; read it using readEmployee() function; and
print it using printEmployee() function.