Â
In this we are going to see how to make a very basic Railway Ticket Counter Program in C++.
The code given below can be used for TURBO C++ Compiler:-
#include<iostream.h>
#include<string.h>
#include<conio.h>
void main()
{
clrscr();
string a,b;
int c;
cout<<"Enter your source station \n";
cin>>a;
cout<<"Enter your destination \n";
cin>>b;
cout<<"Do you want single or return ticket \n 0 : Single ticket \n 1 : Return Ticket";
cin>>c;
switch (c)
{
case 0:
if(c==0)
{
cout<<"You asked for single ticket \n Your single ticket is printed from "<<a <<" "<<"to"<<" "<<b<<"\n";
}
break;
case 1:
if(c==1)
{
cout<<"You asked for return ticket \n Your return ticket is printed from "<<a <<" "<<"to"<<" "<<b<<"\n";
}
break;
}
cout<<"HAPPY AND SAFE JOURNEY"<<endl;
getch();
}
The code given below can be used for g++/gcc Compiler:-
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
string a,b;
int c;
cout<<"Enter your source station \n";
cin>>a;
cout<<"Enter your destination \n";
cin>>b;
cout<<"Do you want single or return ticket \n 0 : Single ticket \n 1 : Return Ticket";
cin>>c;
switch (c)
{
case 0:
if(c==0)
{
cout<<"You asked for single ticket \n Your single ticket is printed from "<<a <<" "<<"to"<<" "<<b<<"\n";
}
break;
case 1:
if(c==1)
{
cout<<"You asked for return ticket \n Your return ticket is printed from "<<a <<" "<<"to"<<" "<<b<<"\n";
}
break;
}
cout<<"HAPPY AND SAFE JOURNEY"<<endl;
return 0;
}
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP