an airport is developing a computer simulation of air traffic control that handl
ID: 3548804 • Letter: A
Question
an airport is developing a computer simulation of air traffic control that handles events such as
landing and takeoffs. each event has time stamp that denotes time in HHMMSS when event occurs.
program should do following operations
1. insert an event with time stamp.
2. extract the event with smallest time stamp.
use required any data structure.
-program should create new event
-insert new even with time stamp
-extract the event with smallest time stamp
-dispaly function to display all events
Explanation / Answer
#include<stdio.h>
#include<conio.h>
struct event
{
char timestamp[10][6];
int count;
};
int main()
{
int small=0;
char c='n';
event ob;
ob.count=0;
do
{
printf(" Enter timestamp to enter event HHMMSS:");
scanf("%s",ob.timestamp[ob.count++]);
printf(" Continue? y/n: ");
scanf("%s",&c);
}while(c!='n');
for(int j=0;j<6;j++)
{
for(int i=1;i<ob.count-1;i++)
{
if(ob.timestamp[small][j]<ob.timestamp[i][j])
{
small = i;
break;
}
}
}
printf("Smallest timestamp: %s", ob.timestamp[small]);
for(int i=0;i<ob.count;i++)
{
printf(" timestamp: %s", ob.timestamp[i]);
}
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.