/* Travel Agency Manager: Ask your n drivers their name, driving license number, route and kms they have drive with us and print these details. */
#include <stdio.h>
struct driver{
char name[100];
char dl[20];
char route[100];
int km;
};
int main()
{
int n, i;
printf("Enter the number of drivers: ");
scanf("%d", &n);
struct driver d[n];
for(i = 0; i < n; i++){
printf("\nDriver %d, please enter your following details...\n", i+1);
fflush(stdin);
printf("Enter your name: ");
gets(d[i].name);
printf("Enter your driving license number: ");
gets(d[i].dl);
printf("Enter your driving route: ");
gets(d[i].route);
printf("Enter km traveled with us by you: ");
scanf("%d", &d[i].km);
printf("Thank you !!! Have a good day.\n");
}
for(i = 0; i < n; i++){
printf("\nPrinting details of driver %d...\n", i+1);
printf("Name: %s\nDriving License Number: %s\nDriving Route: %s\nDistance with us: %dkm\n", d[i].name, d[i].dl, d[i].route, d[i].km);
}
return 0;
}
Comments
Post a Comment