Home
Diploma Practice C Online People
Certificate Contact Us

Assignments on defining and using structure variables


1. Define a structure variable of type 'struct Time' as given below:
   struct Time
   {
     char hour;
     char min;
     char sec;
   }; 

   Note that the structure fields hour, min and sec are char (small) integers.
   Small integers are sufficient to store the time values.
   Ask the user to enter hours, minutes and seconds. Read those values into
   the structure. Finally print the time structure with the format 'HH:MM:SS'.

2. Define a structure variable of type 'struct Date' as given below:
   struct Date
   {
     char  date;
     char  month;
     short year;
   }; 

   Ask the user to enter date and read into  the structure variable.
   Finally print the values in the structure variable in the format
   'DD/MM/YYYY'. Again print the date in the format 'DD MMM YYY', where
   MMM is the name of the month in three characters like 'Jan' .. 'Dec'.

3. Define a structure variable of type 'struct Student' as given below:
   struct Student 
   {
     char  name[40];
     long long mobile;
     struct Date dob; //Date of birth, struct Date as given in assignment 2. 
   }; 

   Ask the user to enter the student information, and fill the defined 
   structure variable. Finally print the studnent informaiton in the
   following format:
 
   Name   : Bharat Kumar B
   Mobile : 9393916923
   DOB    : 18/10/1994

   Note that, name may have multiple words.
 
4. Define an array of 5 structure variables of type 'struct Student'
   Read from the user, information of 5 students in to this array.
   Finally print the array in the following format:

   S.No    Name              Mobile      Date of Birth
   ----    ----------------- ----------  -------------     
      1    Bharat Kumar B    9393916923  18/10/1994
      --    --                --         --
      5    xxxxx xxxxxx x    xxxxxxxxxx  xx/xx/xxxx





#401, Sai Sushma Homes, 23/A, S.R. Nagar Main Road, Hyderabad-500038, India.
Ph: +91-40-48508764, 7702028989, depik.help@gmail.com