Problem:
How to create a Bus Reservation System using C
Code:
#include<stdio.h>
#include<conio.h>
#include<string.h>
char name[20];
void main()
{
int b;
clrscr();
printf("\n*******WELCOME TO BUS RESERVATION SYSTEM************");
printf("\nEnter passenger name:");
scanf("%s",&name);
printf("\nMENU\n1.Seats Available\n2.Cost of Journey\n3.exit");
scanf("%d",&b);
switch(b)
{
case 1:
seat();
break;
case 2:
cost();
break;
case 3:
exit(0);
default:
printf("\nYou entered wrong choice");
}
getch();
}
seat()
{
long int n,b,a,d;
printf("\nmr.%s\nEnter the Bus Number",name);
scanf("%ld",&n);
if(n>2564123 && n<9740213)
{
b=(n%1000)+(n%100)+(n%10);
printf("\nmr.%s\nThe available seats in bus are:%d",name,b);
}
else
{
printf("\nmr.%s\nYou entered wrong bus number",name);
printf("\nmr.%s\nPlease select from Menu\nEnter 1 to check bus numbers\n2 to Exit",name);
scanf("%ld",&a);
if(a==1)
{
for(d=2564123;d<9740213;d=d+25)
{
printf("\n%ld",d);
}
}
else if(a==2)
{
exit(0);
}
else
{
printf("\nmr.%s\nYou entered Wrong Choice",name);
}
}
}
cost()
{
int a,b,c;
char to[10],from[10];
printf("\nFROM:");
scanf("%s",&from);
printf("\nTO:");
scanf("%s",&to);
a=strlen(to);
b=strlen(from);
c=((a*b)+(a*b)+(a+2)*(b+2))*2;
printf("\nmr.%s\nCost of Journey from %s to %s is %d",name,from,to,c);
}
How to create a Bus Reservation System using C
Code:
#include<stdio.h>
#include<conio.h>
#include<string.h>
char name[20];
void main()
{
int b;
clrscr();
printf("\n*******WELCOME TO BUS RESERVATION SYSTEM************");
printf("\nEnter passenger name:");
scanf("%s",&name);
printf("\nMENU\n1.Seats Available\n2.Cost of Journey\n3.exit");
scanf("%d",&b);
switch(b)
{
case 1:
seat();
break;
case 2:
cost();
break;
case 3:
exit(0);
default:
printf("\nYou entered wrong choice");
}
getch();
}
seat()
{
long int n,b,a,d;
printf("\nmr.%s\nEnter the Bus Number",name);
scanf("%ld",&n);
if(n>2564123 && n<9740213)
{
b=(n%1000)+(n%100)+(n%10);
printf("\nmr.%s\nThe available seats in bus are:%d",name,b);
}
else
{
printf("\nmr.%s\nYou entered wrong bus number",name);
printf("\nmr.%s\nPlease select from Menu\nEnter 1 to check bus numbers\n2 to Exit",name);
scanf("%ld",&a);
if(a==1)
{
for(d=2564123;d<9740213;d=d+25)
{
printf("\n%ld",d);
}
}
else if(a==2)
{
exit(0);
}
else
{
printf("\nmr.%s\nYou entered Wrong Choice",name);
}
}
}
cost()
{
int a,b,c;
char to[10],from[10];
printf("\nFROM:");
scanf("%s",&from);
printf("\nTO:");
scanf("%s",&to);
a=strlen(to);
b=strlen(from);
c=((a*b)+(a*b)+(a+2)*(b+2))*2;
printf("\nmr.%s\nCost of Journey from %s to %s is %d",name,from,to,c);
}
No comments:
Post a Comment