100% found this document useful (2 votes)
92 views1 page

C-Structures and Unions-And Functions 10

The document discusses structures and unions in C programming. It provides 6 questions to write programs using structures. The questions cover creating structures with different data members, reading and printing structure variables and arrays, and defining functions to read, print and compute values for structure members.

Uploaded by

vinitajenny
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
92 views1 page

C-Structures and Unions-And Functions 10

The document discusses structures and unions in C programming. It provides 6 questions to write programs using structures. The questions cover creating structures with different data members, reading and printing structure variables and arrays, and defining functions to read, print and compute values for structure members.

Uploaded by

vinitajenny
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

Structures and Unions and functions

#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.

You might also like