Hello, fellow campers,
I have been a project in C lang.
The project’s focus is to get the info from the end-user.
It is based on a train booking.
The problem is when I get the no. of passengers. if it is 2 then, I ask for some info, after asking, it did not run the next code.
Here is my Code
#include <stdio.h>
#include <stdlib.h>
int main()
{
char Fname[10];
char Lname[10];
int age;
int no_people;
int phone;
char state_des[10];
char city_des[10];
char station_des[10];
char state_origin[10];
char city_origin[10];
char station_origin[10];
char secpass[10];
char thrpass[10];
char fourpass[10];
char fivepass[10];
int secpass_age;
int thrpass_age;
int fourpass_age;
int fivepass_age;
printf ("Enter your First Name: ");
scanf ("%s",Fname);
printf ("Enter your Last Name: ");
scanf ("%s", Lname);
printf ("Enter your Age: ");
scanf ("%d",&age);
printf ("Enter your Phone Number: ");
scanf ("%d",&phone);
printf ("Enter the Number of Passenger: ");
scanf ("%d",&no_people);
if (no_people == 2)
{
printf ("Enter the Name of the 2th Passenger: ");
scanf ("%s", secpass);
printf ("Enter the Age of the 2th Passenger: ");
scanf ("%d", secpass_age);
} else if (no_people == 3)
{
printf ("Enter the Name of the 2th Passenger: ");
scanf ("%s", secpass);
printf ("Enter the Age of the 2th Passenger: ");
scanf ("%d", secpass_age);
printf ("Enter the Name Of the 3th Passenger: ");
scanf ("%s", thrpass);
printf ("Enter the Age of the 3th Passenger: ");
scanf ("%d", thrpass_age);
} else if (no_people == 4)
{
printf ("Enter the Name of the 2th Passenger: ");
scanf ("%s", secpass);
printf ("Enter the Age of the 2th Passenger: ");
scanf ("%d", secpass_age);
printf ("Enter the Name Of the 3th Passenger: ");
scanf ("%s", thrpass);
printf ("Enter the Age of the 3th Passenger: ");
scanf ("%d", thrpass_age);
printf ("Enter the Name of the 4th Passenger: ");
scanf ("%s", fourpass);
printf ("Enter the age of the 4th Passenger: ");
scanf ("%d", fourpass_age);
} else if (no_people == 5);
{
printf ("Enter the Name of the 2th Passenger: ");
scanf ("%s", secpass);
printf ("Enter the Age of the 2th Passenger: ");
scanf ("%d", secpass_age);
printf ("Enter the Name Of the 3th Passenger: ");
scanf ("%s", thrpass);
printf ("Enter the Age of the 3th Passenger: ");
scanf ("%d", thrpass_age);
printf ("Enter the Name of the 4th Passenger: ");
scanf ("%s", fourpass);
printf ("Enter the age of the 4th Passenger: ");
scanf ("%d", fourpass_age);
printf ("Enter the Name of the 5th Passenger: ");
scanf ("%s", fivepass);
printf ("Enter the age of the 5the Passenger" );
scanf ("%d", fivepass_age);
} else {
return "Please choose the number between 2-5";
}
printf ("Enter the State of the Origin: ");
scanf ("%s", state_origin);
printf ("Enter the City of the Origin: ");
scanf ("%s", city_origin);
printf ("Enter the railway station of the Origin: ");
scanf ("%s", station_origin);
printf ("Enter the State you want to go: ");
scanf ("%s", state_des);
printf ("Enter the City you want to go: ");
scanf ("%s", city_des);
printf ("Enter the Name of the Railway Station: ");
scanf ("%s", station_des);
}
Hope you understand the given info.
If you need more info, please let me know.
Thanks and Happy Coding!