Structure data type Program in C
Define a structure data type TRAIN_INFO. The type contain Train No.: integer type Train name: string Departure Time: aggregate type TIME Arrival Time: aggregate type TIME Start station: string End station: string The structure type Time contains two integer members: hour and minute. Maintain a train timetable and implement the following operations:
(i) List all the trains (sorted according to train number) that depart from a particular section.
(ii) List all the trains that depart from a particular station at a particular time.
(iii) List all he trains that depart from a particular station within the next one hour of a given time.
(iv) List all the trains between a pair of start station and end station.
#include<stdio.h>
#include <string.h>
struct stu
{ int roll;
char name[50];
}st1,st2; //declaring variables for structure
int main( )
{
//store first student information
st1.roll=101;
strcpy(st1.name, "Amit");
//store second student information
st2.roll=102;
strcpy(st2.name, "Manoj");
//printing first student information
printf( "student 1 roll : %d\n", st1.roll);
printf( "student 1 name : %s\n", st1.name);
//printing second student information
printf( "student 2 roll : %d\n", st2.roll);
printf( "student 2 name : %s\n", st2.name);
return 0;
}
Output:
student 1 roll : 101 student 1 name : Amit student 2 roll : 102 student 2 name : Manojb. tech. c language tutorial learn c language study c language