Department of Electronics & Communication Engineering
Department of Electronics & Communication Engineering
Tutorial – 10
Subject : PPS
Class : B. Tech. Sem.I (EC)
int main()
{
union a
{
int i;
char ch[2];
};
union a u;
u.ch[0]=3;
u.ch[1]=2;
printf("%d, %d, %d\n", u.ch[0], u.ch[1], u.i);
return 0;
}
(6) #include<stdio.h>
int main()
{
struct value
{
int bit1:1;
int bit3:4;
int bit4:4;
}bit={1, 2, 13};
Q.4 Do as directed.
(1) Define a structure data type called time_struct containing three members integer hour,
integer minute and integer second. Develop a program that would assign values to the
individual members and display the time in the following form:
16:40:51
(2) Create two structures named metric and British which store the values of distances.
The metric structure stores the values in metres and centimetres and the British
structure stores the values in feet and inches. Write a program that reads values for the
structure variables and adds values contained in one variable of metric to the contents
of another variable of British. The program should display the result in the format of
feet and inches or metres and centimetres as required.
(3) Define a structure that can describe an hotel. It should have members that include the
name, address, grade, average room charge, and number of rooms.
Write functions to perform the following operations:
(a) To print out hotels of a given grade in order of charges
(b) To print out hotels with room charges less than a given value
(4) Define a structure called cricket that will describe the following information:
player name
team name
batting average
Using cricket, declare an array player with 50 elements and write a program to read
the information about all the 50 players and print a team-wise list containing names of
players with their batting average.
(5) Write a C program that prints the size of a structure data type.
* * *