C Program Manual
C Program Manual
NAME :_________________________________________________
REGISTER NO.
DEPARTMENT : _________________________________________________
:_________________________________________________
SUBJECT CODE
BONAFIDE CERTIFICATE
NAME :_______________________________________________________
REGISTER NO.
DEPARTMENT :______________________________________________________
COURSE :_______________________________________________________
by........…………………………….……………..........................…………………in
8 Populate a two dimensional array with height and weight of persons and
compute the Body Mass Index of the individuals.
9 Given a string ―a$bcd./fg‖ find its reverse without changing the
position of special characters.(Example input:a@gh%;j and
output:j@hg%;a)
10 Given a string ―a$bcd./fg‖ find its reverse without changing the
position of special characters.(Example input:a@gh%;j and
output:j@hg%;a)
11 From a given paragraph perform the following using built-in functions:
a. Find the total number of words.
b. Capitalize the first word of each sentence.
c. Replace a given word with another word.
12 Solve towers of Hanoi using recursion.
Aim:
To write C program to swap two numbers using temporary variable
Algorithm:
1. Start
2. Read two numbers a,b
3. Assign t=a;a=b;b=a;
4. Print two numbers a,b
5. Stop.
Program:
#include<studio.h>
#include<conio.h>
void main()
{
int a,b,t;
clrscr();
printf(“Enter two numbers:”);
scanf(“%d%d”,&a,&b);
t=a;
a=b;
b=t;
printf(“Numbers after swap:a=%d and b=%d”,a,b);
getch();
}
Sample Output:
Enter two numbers: 8
16
Number after swap: a=16 and b=8
Result:
Aim:
To write a C program to find biggest among two numbers using ternary operator
Algorithm:
1. Start
2. Read two numbers
3. Use Ternary operator to find biggest number(i.e) (a>b)?a:b;
4. Print biggest number
5. Stop
Program
#include<studio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf(“Enter the value of a and b”);
scanf(“%d%d”,&a,&b);
c=a>b?a:b;
printf(“Biggest number=%d”,c);
getch();
}
Sample Output
Enter the value of a and b: 30
70
Biggest number=70
Result:
Aim:
To write a C program to find biggest among three numbers
Algorithm:
1. Start
2. Read three numbers a, b,c;
3. Compare a and b. If a is greatest perform step 4 else perform step 5.
4. Compare a and c. If a is greatest print biggest number is A. Else print biggest
number is C
5. Compare b and c. If b is greatest print biggest number is B. Else print biggest
number is C.
6. Stop.
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
printf(“Enter three numbers\n”);
scanf(“%d%d%d”,&a,&b,&c);
if(a>b)
{
if(a>c)
{
printf(“The biggest number is=%d”,a);
}
else
{
printf(“The Biggest number is=%d”,c);
}
}
else
{
if(b>c)
{
printf(“The biggest number is=%d”,b);
}
else
{
printf(“The biggest number is=%d”,c);
}
}
getch();
}
Sample Output:
Enter three numbers
90
45
12
The biggest number is =90
Result:
Aim:
To write a C program to find the roots of a quadratic equation.
Algorithm:
1. Start
2. Enter three coefficients a,b,c.
3. Calculate d=b*b-4*a
4. Check if d=0 then roots are equal, and calculate root1=root2=-b/(2.0*a)
5. if d>0 then roots are real and distinct. Calculate root1=-b(2.0*a)
root1=(-b+sqrt(d))/(2*a)
root2=(-b-sqrt(d))/(2*a)
6. if d<0 then roots are imaginary root contains real and imaginary parts.
Calculate realp=-b(2*a),
imagp=sqrt(d)/(2*a) and
root1=real p+iimgp
root2=real p+iimgp.
7. Display root1, root2.
8. Stop.
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
float root1,root2,realp,imgp,a,b.c.d;
clrscr();
printf(“Enter three coefficient of quadratic equation”);
scanf(“%f%f%f”,&a,&b,&c);
d=b*b-4*a*c;
if(d==0)
{
printf(“roots are equal\n”);
root1=root2=-b(2*a);
printf(“root1=root2=%f\n”,root1);
}
else if(d>0)
{
printf(“roots are real and distinct\n”);
root1=(-b+sqrt(d))/(2*a);
root2=(-b-sqrt(d))/(2*a);
printf(“root1=%f\n”,root1);
printf(“root2=%f\n”,root2);
}
else
{
printf(“roots are imaginary\n”);
realp=-b/(2*a);
imgp=sqrt(-d)/(2*a);
printf(“root1=%f+i %f\n”,realp,imgp);
printf(“root2=%f-i %f\n”,realp,imgp);
}
getch();
}
Sample output:
Enter three coefficient of quadratic equation
1
2
1
Roots are equal
roots1=root2=-1.000
Result:
Aim:
To write a C program to find a factorial number.
Algorithm:
1. Start
2. Read number n.
3. Initialize i=1 and fact=1
4. Calculate fact=fact*i till i=n.
5. Increment i=i+1
6. Print fact
7. Stop
Program
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,fact=1;
clrscr();
printf(“Enter the number”);
scanf(“%d”,&n);
for(i=1;i<=n;i++)
fact=fact*i;
printf(“The factorial of %d is =%d”,n.fact);
getch();
}
Sample Output:
Enter the number: 6
The Factorial of 6 is =720
Result:
Aim:
To write a C program to generate a Fibonacci series.
Algorithm:
1. Start
2. Read number
3. Assign f1=0,f2=1;
4. Set loop for i and for all i<number value and calculate f3=f1+f2
5. Display f1
6. Assign f1=f2 and f2=f3;
7. Stop.
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int num,i;
int f1=0,f2=1,f3;
printf(“Enter n number:”);
scanf(“%d”,&num);
for(i=1;i<=num;i++)
{
f3=f1+f2;
printf(“%5d”,f1)
f1=f2;
f2=f3;
}
getch();
}
Sample Output:
Enter n numbers:5
01123
Result:
Aim:
To write a C program to check prime number.
Algorithm:
1. Start
2. Read n.
3. From i=2 to n/2 divide the number by 1.
4. If the number is divided by any other numbers then that number is not prime.
5. If the number is not divisible by any other numbers then that number is prime.
6. Display the result.
7. Stop
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,count;
count=0;
printf(“Enter n value”);
scanf(“%d”,&n);
for(i=2;i<=n/2;i++)
{
if(n%1==0)
{
count++;
}
if(count==0)
{
printf(“Prime”);
}
else
{
printf(“Not prime”);
}
}
getch();
}
Sample Output:
Enter n Value 163
Prime
Enter n value 235
Not prime
Result:
Aim:
To write a C program to print multiplication table
Algorithm:
1. Start
2. Read a
3. Initialize i=1
4. Calculate b=a*i and print the values in the format a*i=b
5. Increment i=i+1
6. Repeat step 4 till i=10
7. Stop
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int i,a,b;
a=0;
clrscr();
printf(“Enter the number”);
scanf(“%d”,&a);
for(i=1;i<=10;i++)
{
b=a*i;
printf(“%d * %d=%d\n”,a,i,b);
}
getch();
}
Sample Output
Enter the number 5
5*1=5
5*2=10
5*3=15
5*4=20
5*5=25
Result:
Aim:
To write a C program to check whether given number is palindrome number or not
Algorithm:
1. Start
2. Read n
3. Assign rev=0 and temp=h;
4. Calculate
r=n%10
rev=rev*10+r
n=n/10
5. Repeat step4 till n>0
6. Check whether the values of temp and reverse equal
7. If both are equal then print number is palindrome
8. If both are not equal then print number is not palindrome
9. Stop
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int n,r,rev,temp;
rev=0;
clrscr();
printf(“\nEnter the number :”);
scanf(“%d”,&n);
temp=n;
while(n>0)
{
r=n%10;
rev=rev*10+r;
n=n/10;
}
printf(“The reversed of number %d is =%d\n”,temp,rev);
if(temp==rev)
printf(“It is palindrome”);
else
printf(“It is not palindrome”);
getch();
}
Sample Output:
Enter the number 151
The reversed of number 151 is =151
It is palindrome.
Result:
Aim:
To write a C program to check given year is leap or not
Algorithm:
1. Start
2. Read year
3. Check
Year%400=0 or year%4=0 and year%100!=0
4. If the above condition is true then print given year is aleap year
5. If the above condition is false then print given year is not leap year.
6. Stop
Program:
#include <stdio.h>
int main()
{
int year;
printf("Enter a year: ");
scanf("%d",&year);
if((year%400==0)||(year%4 == 0 && year%100!=0))
{
printf("%d is a leap year.", year );
}
else
printf("%d is not a leap year.", year);
return 0;
}
Sample output
Enter a year: 1900
1900 is not a leap year.
Result:
Aim:
To design a calculator to perform addition, subtraction, multiplication, division and square
of a number.
Algorithm:
1. Start
2. Display the menu
3. Read the choice
4. If choice perform the corresponding operations addition, subtraction,
multiplication, division and square
5. If the last choice to exit the functions.
6. Stop.
Program:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
int ch;
float a,b,res;
clrscr();
printf(“nMenu\n1.Additionn2.Subtractionn3.Multiplication 4.Division 5.Squre and
6.Exit”);
printf(“nEnter your choice:”);
scanf(“%d”,&ch);
if(ch<6)
{
if(ch!=5)
{
printf(“Enter two numbers:”);
scanf(“%f%f”,&a,&b);
}
Else
{
printf(“Enter two numbers:”);
scanf(“%f”,&a);
}
}
do
{
switch(ch)
{
case 1: res=a+b;
break;
case 2: res=a-b;
break;
case 3: res=a*b;
break;
case 4: res=a/b;
break;
case 5: res=a*a;
break;
case 5: exit(0);break;
default: printf(“Wrong choice!!nPress any key…”);
break;
}
}while(ch!=6);
printf(“nResult=%f”,res);
getch();
}
Sample Output:
Menu
1. Addition
2. Subtraction
3. Multiplication
4. Division
5. Square
6. Exit
Enter choice: 1
Enter two numbers
11
11
Resukt=22.00
Menu
1. Addition
2. Subtraction
3. Multiplication
4. Division
5. Square
6. Exit
Enter choice: 6
Result:
Aim:
To write a C program to check given number is Armstrong number or not.
Algorithm:
1. Start
2. Read n
3. Store n into another variable num
4. If n!=0 then calculate
r=n%10
sum=sum+r*r*r
n=n/10
5. Check whether sum equal to num or not. If both numbers equal then print number
is Armstrong number .
6. Otherwise print number is not Armstrong number
7. Stop
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int n,sum,num,r;
sum=0;
printf(“Enter the number”);
scanf(“%d”,&n);
num=n;
while(n!=0)
{
r=n%10;
sum=sum+r*r*r;
n=n/10;
}
if(sum==num)
printf(“Entered number is Armstrong number:”);
else
printf(“Entered number is not Armstrong number”);
}
Sample Output
Enter the number:371
Entered number is Armstrong number
Result:
Aim:
To write a C program to find the sum of weights and sort the numbers
Algorithm:
1. Start
2. Read n
3. Read n numbers
4. Initialize sum=0
5. Check whether the number is perfect cube or not. If it is perfect cube then add
sum=sum+5
6. Check whether the number is multiple of 4 and divisible by 6 or not. If the
conditions are true then add sum=sum+4
7. Check whether the number is prime number or not. If it is a prime number then add
sum=sum+3
8. Sort and print the array
9. Stop
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int n,a[10],i,j,k,x,c,count,sum=0,sum_array[10],temp;
int temp1;
clrscr();
printf(“Enter n number(1-10)”);
scanf(“%d”,&n);
printf(“Enter %d elements”,n);
for(i=0;i<n;i++)
scanf(“%d”,&a[i]);
//Checking perfect cube
for(i=0;i<n;i++)
{
j=a[i]/2;
for(k=2;k<=j;k++)
{
if(a[i]%k==0)
if(k*k*k==a[i])
sum+=5;
}
//checking multiple of 4 and divisible by 6
if(((a[i]%4)==0)&&((a[i]%6)==0))
sum+=4;
//checking prime number
Count=0;
for(x=2;x<a[i]/2;x++)
{
if(a[i]/x==0)
count++;
}
if(count==0)
sum+=3;
sum_array[i]=sum;
sum=0;
}
printf(“\n”);
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(sum_array[i]>sum_array[j])
{
temp=sum_array[i];
temp1=a[i];
sum_array[i]=sum_array[i];
a[i]=a[j];
sum_array[j]=temp;
a[j]=temp1;
}
}
}
printf(“\nThe Sorted array is”);
for(i=0;i<n;i++)
printf(“<%d,%d>\n”,a[i],sum_array[i]);
getch();
}
Sample Output:
Enter n number(1-10):6
Enter 6 elements:10
36
54
89
12
27
The sorted array is
<10,3>
<36,3>
<54,3>
<89,7>
<12,7>
<27,8>
Result:
Aim:
To write a C program to find number of persons above the average height.
Algorithm:
1. Start
2. Read n
3. Populate height of n persons
4. Find the average by sum/n
5. Sort the height
6. Read every element if its above the average height then increment count.
7. Print count value
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,temp,n,sum=0,avg,a[20],count=0;
clrscr();
printf(“Enter how many persons? :”);
scanf(“%d”,&n);
printf(“\Populate height of %d persons\n”,n);
for(i=0;i<n;i++)
scanf(“%d”,&a[i]);
for(i=0;i<n;i++)
sum=sum+a[i];
avg=sum/n;
printf(“Average height is=%d\n”,avg);
for(i=0;i<n;i++)
{
for(j=i+1;;j<n;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
for(i=0;i<n;i++)
printf(“%d\t”,a[i]);
for(i=0;i<n;i++)
{
if(a[i]>=avg)
{
Count=count++;
}
}
printf(“\n%d persons above average height”,count);
getch();
}
Sample Output
Enter how many persons?
5
Populate height of 5 persons
46
78
39
61
59
Average height is=56
39 46 59 61 78
3 persons above average height...
Result:
Aim:
To write a C program to compute the body mass index
Algorithm:
1. Start
2. Read n
3. Read weight and height of n persons
4. Calculate
Bmi=weight/(height*height)
5. Print bmi
6. Stop
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
int x,bmi=0.0;
float hw[10][10];
clrscr();
printf(“Enter how many persons”);
scanf(“%d”,&n);
printf(“\n Populate weight in kg and height in meters(like 1.75m)\n”);
for(i=0;i<n;i++)
{
for(j=0;j<2;j++)
{
scanf(“%f\n”,&hw[i][j]);
}
}
printf(“weight \tand\t Height”);
for(i=0;i<n;i++)
{
for(j=0;j<2;j++)
printf(“%f\t”,hw[i][j]);
printf(“\n”);
}
for(i=0;i<n;i++)
{
for(j=0;j<2;j++)
{
x=hw[i][0]/hw[i][1];
bmi=x/hw[i][1];
}
printf(“The body mass index of persons %d is=%d\n”,i,bmi);
}
getch();
}
Sample Output:
Enter how many persons 3
Populate weight in kg and height in meters (like 1.75m)
70 1.75
80 1.79
60 1.70
Weight and height
70.000 1.7500
80.000 1.7900
60.000 1.7000
The body mass index of person 1 is =22
The body mass index of person 2 is =24
The body mass index of person 3 is=20
Result:
Aim:
To write a C program to reverse the string without changing the position of special
characters.
Algorithm:
1. Start
2. Read the string
3. Calculate the string length using the sting length using strlen.
4. Traverse the string from both ends and check it is passed special character or not
5. If it is special character just move to next character
6. If it is not special character swap both characters
7. Repeat steps 4 to 6. Until traverse all the characters
8. Print reverse string
9. Stop
Program:
#include<stdio.h>
#include<conio.h>
isAlphabet(char x)
{
Return((x>=’A’&&x<=’Z’)||(x>=’a’&&x<=’z’));
}
void reverse(char x)
{
char tmp;
int r=strlen(str)-1,l=0;
//traverse string from both end
while(l<r)
{
//ignore special character
if(!isAlphabet(str[l]))
i++;
else if(!isAlphabet(str[r]))
r--;
else
{
tmp=str[l];
str[l]=str[r];
str[r]=tmp;
l++;
r--;
}
}
}
void main()
{
char str[20];
clrscr();
printf(“Input string:\n”);
scanf(“%s”,str);
reverse(str);
printf(“Output is:%s”,str);
getch();
}
Sample Output:
Input string:
a@gh%;j
Output String:j@hg%;a
Result:
Aim:
To write a C program to convert decimal number to binary, octal and hexadecimal
Algorithm:
1. Start
2. Read n
3. To convert n to any other base divide n to the base to be converted
4. Get the remainder and store it in the array
5. Use the quotient as new n and repeat setp3 and 4. Until n becomes 0.
6. Print the remainder array in reverse order.
7. Stop
Program:
#include<stdio.h>
void main()
{
int CH,NUM;
void octal(int);
void binary(int);
void hexa(int);
clrscr();
printf("ENTER DECIMAL NUMBER TO BE CONVERTED: \n");
scanf("%d",&NUM);
printf("\nSELECT CONVERSION");
printf("\n 1. DECIMAL TO BINARY\n");
printf("\n 2. DECIMAL TO OCTAL\n");
printf("\n 3. DECIMAL TO HEXADECIMAL\n");
printf("\nENTER CHOICE HERE :");
scanf("%d",&CH);
switch(CH)
{
case 1 : binary(NUM);
break;
case 2 : octal(NUM);
break;
case 3 : hexa(NUM);
break;
default : printf("\nYOU HAVE ENTERED WRONG CHOICE !!!");
}
getch();
}
void hexa(int Y)
{
char HEXC[5];
int NUM,I,LEN,HEXD[5];
NUM=Y;
LEN=0;
while(Y>0)
{
HEXD[LEN]=Y%16;
Y=Y/16;
LEN++;
}
for(I=LEN-1;I>-1;I--)
{
if(HEXD[I]<10)
HEXC[I]=HEXD[I]+48;
else
HEXC[I]=HEXD[I]+55;
}
printf("\nCONVERTED BINARY EQUIVALENT VALUE OF %d IS \t",NUM);
for(I=LEN-1;I>-1;I--)
{
printf(FP,"%c",HEXC[I]);
}
}
void binary(int Y)
{
int NUM,I,LEN,BIN[20];
NUM=Y;
LEN=0;
while(Y>0)
{
BIN[LEN]=Y%2;
Y=Y/2;
LEN++;
}
printf("\nCONVERTED BINARY EQUIVALENT VALUE OF %d IS \t",NUM);
for(I=LEN-1;I>-1;I--)
{
printf(FP,"%d",BIN[I]);
}
}
void octal(int Y)
{
int NUM,I,LEN,OCT[5];
NUM=Y;
LEN=0;
while(Y>0)
{
OCT[LEN]=Y%8;
Y=Y/8;
LEN++;
}
printf("\nCONVERTED OCTAL EQUIVALENT VALUE OF %d IS \t",NUM);
for(I=LEN-1;I>-1;I--)
{
printf(FP,"%d",OCT[I]);
}
}
Sample Output:
ENTER DECIMAL NUMBER TO BE CONVERTED: 555
SELECT CONVERSION
1. DECIMAL TO BINARY
2. DECIMAL TO OCTAL
3. DECIMAL TO HEXADECIMAL
ENTER CHOICE HERE: 1
CONVERTED BINARY EQUIVALENT VALUE OF 555 IS 1000101011
Result:
Aim:
To write a C program to find total number of words in a paragraph, to capitalize the first
word of each sentence and to replace a given word with another word.
Algorithm: To find total number of words in a paragraph.
1. Start
2. Read the paragraph
3. Read one character at a time if any blank space then increment the word count
variable by 1.
4. Print count.
5. Stop.
Algorithm: to capitalize the first word of each sentence
1. Start
2. Read the paragraph
3. Capitalize the first character of the paragraph using toupper built in function.
4. Read one character at a time, and check if it is a full stop (.) then capitalize the next
character.
5. If any uppercase in between the sentence change it to lowercase letter.
6. Print the paragraph
7. Stop.
Algorithm: To replace a given word with another word.
1. Start
2. Read a sentence
3. Read search and replace strings
4. Write a user defined function to replace the search string with the replace string.
5. Recursively call using the function until there is no occurrence of the search string.
6. Print the new paragraph
{
char str[MAX]={0};
int i;
clrscr();
printf(“Enter a string:”);
scanf(“%[^\n]s”,str);//read string with spaces
//capitalize first character of each sentence
for(i=0;str[i]!=’\0’;i++)
{
if(i==0)
{
if(str[i]>=’a’&&str[i]<=’z’)
str[i]=toupper(str[i]);
continue;
}
if(str[i]==’.’)//check sentence
{
i++;
if(str[i]>=’a’&&str[i]<=’z’)
{
str[i]=toupper(str[i]);
continue;
}
}
else
{
if(str[i]>=’A’&&str[i]<=’Z’)
str[i]=tolower(str[i]);
}
}
printf(“Capitalized string is:%s\n”,str);
getch();
}
if(ret==NULL)
exit(EXIT_FAILURE);
i=0;
while(*s)
{
if(strstr(s,old)==s)//change the substring with the new string
{
strcpy(&ret[i],new1);
i+=newlen;//adding newlength to the new string
s+=oldlen;//adding the same old length the old string
}
else
ret[i++]=s*++;
}
ret[i]=’\0’;
return ret;
}
void main()
{
char mystr[100],c[10],d[10];
char *newstr=NULL;
printf(“Enter a string along with character to be rep_strd:\n”);
gets(mystr);
printf(“enter the character to rep_strd:\n”);
scanf(“%s”,c);
printf(“Enter the new character:\n”)
scanf(“%s”,d);
puts(mystr);
newstr=rep_str(mystr,c,d)
printf(“%s\n”,newstr);
free(newstr);
getch();
}
Sample output:
b) Enter a String: hai hello how are you. this is sam, bye
Capitalize string is:Hai hello how are you. This is sam, bye.
Result:
Aim:
To write a C program to solve towers of Hanoi using recursion.
Algorithm:
1. Start
2. Read number of disk as num
3. If num=1 move the disk from frompeg to topeg
4. Else repeatedly move disk(num-1,frompeg,anuxpeg,topeg)
5. Print the sequence of moves
6. Stop
Program:
#include <stdio.h>
void towers(int, char, char, char);
int main()
{
int num;
printf("Enter the number of disks : ");
scanf("%d", &num);
printf("The sequence of moves involved in the Tower of Hanoi are :\n");
towers(num, 'A', 'C', 'B');
return 0;
}
Sample Output:
Enter the number of disks: 3
The sequence of moves involved in the Tower of Hanoi are :
Result:
Aim:
To write a C program to sort n numbers using pass by reference
Algorithm:
1. Start
2. Read n
3. Read n numbers
4. Call the function sort by passing the address of two numbers to swap
In sort function receive the numbers and using temporary variable swap two
numbers
5. Repeat step 4 until all number are stored
6. Print the sorted array
7. Stop
Program
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,j;
int a[10];
clrscr();
printf(“Enter n”);
scanf(“%d”,&n);
printf(“Enter n numbers\n”);
for(i=0;i<n;i++)
scanf(“%d”,&a[i]);
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
sort(&a[i],&a[j]);
}
}
}
printf(“\nAfter sorting\n”);
for(i=0;i<n;i++)
printf(“%d\t”,a[i]);
getch();
}
int sort(int *x,int *y)
{
int temp;
temp=*x;
*x=*y;
*y=temp;
Return;
Sample Output:
Enter 6
Enter n numbers
7
2
9
3
11
1
After sorting
1 2 3 7 9 11
Result:
Aim:
To write a C program
Algorithm:
1. Start
2. Read number of employees
3. Read employee details and their basic pay,allowance and detections.
4. Calculate the net pay.
5. Print all details
6. Stop.
Program:
#include<stdio.h>
#include<conio.h>
struct emp
{
int empno ;
char name[10] ;
int bpay, allow, ded, npay ;
};
void main()
{
struct emp *ptr
int i, n ;
clrscr() ;
printf("Enter the number of employees : ") ;
scanf("%d", &n) ;
for(i = 0 ; i < n ; i++)
{
printf("\nEnter the employee number : ") ;
scanf("%d", &(ptr+i)-> empno) ;
printf("\nEnter the name : ") ;
scanf("%s", &(ptr+i)->name) ;
printf("\nEnter the basic pay, allowances & deductions : ") ;
scanf("%d %d %d", &(ptr+i)->bpay, &(ptr+i)->allow, &(ptr+i)->ded);
(ptr+i)->npay =(ptr+i)->bpay + &(ptr+i)->allow - &(ptr+i)->ded ;
}
printf("\nEmp. No. Name \t Bpay \t Allow \t Ded \t Npay \n\n");
for(i = 0 ; i < n ; i++)
{
printf("%d \t %s \t %d \t %d \t %d \t %d \n", e[i].empno,
(ptr+i)->name, (ptr+i)->bpay, (ptr+i)->allow, (ptr+i)->ded, (ptr+i)->npay) ;
}
getch() ;
}
Sample Output:
Enter the number of employees : 2
Enter the employee number : 101
Enter the name : Arun
Enter the basic pay, allowances & deductions : 5000 1000 250
Enter the employee number : 102
Result:
Aim:
To write a C program to calculate internal marks of students for five different subjects
using structures and functions.
Algorithm:
1. Start
2. Read number of student
3. For every student get attendance percentage
4. Calculate attendance mark based on the following conditions
Mark=0 if attendance percentage<75
Mark=1 if attendance percentage>76 and 80
Mark=2 if attendance percentage>81 and 85
Mark=3 if attendance percentage>86 and 90
Mark=4 if attendance percentage>91 and 95
Mark=5 if attendance percentage>96 and 100
5. Read 3 internal assessment marks for every subjects
6. Calculate internal mark out of 15 i.e total=((m1+m2+m3)/300)*15 or total =
(m1+m2+m3)*0.05
7. Add attendance mark and total mark to find internal mark.
8. Print the internal mark.
9. Stop
Program:
#include<stdio.h>
Struct student
{
int m1;
int m2;
int m3;
};
void main()
{
struct student s[50];
char subjects[20];
int i,j,n,attmark,subtotal=0,total=0,intmark;
clrscr();
printf(“\nEnter number of students: ”);
scanf(“%d”,&n);
for(i=0;i<n;i++)
{
Attmark=getattendance();
for(j=1;j<=5;j++)
{
printf(“\n\nEnter 3 Internal Assessment Mark for Subject [%d]=\n”,j);
scanf(“%d%d%d”,&s[i].m1,&s[i].m2,&s[i].m3);
subtotal=s[i].m1+s[i].m2+s[i].m3;
total=subtotal*0.05;
intmark=total+attmark;
printf(“\nInternal mark of subject [%d] for student[%d]=%d”,j+1,intmark);
}
}
getch();
}
int getattandance()
{
int attendance,att;
printf(“\n Enter attendance percentage :”);
scanf(“%d”,&attendance);
if(attendance<75)
att=0;
else if(attendance>76&&attendance<80)
att=1;
else if(attendance>81 && attendance<85)
att=2;
else if(attendance>86&&attendance<90)
att=3;
else if(attendance>91 && attendance<95)
att=4;
else if(attendance>96&&attendance<100)
att=5;
return att;
}
Sample Output:
Enter number of students: 1
Enter attendance percentage: 98
Enter 3 internal Assessment mark for subject[1]=98 95 96
Internal Mark of subject[2] for student[1]=19
Enter 3 internal assessment mark for subject[2]=87 99 89
Internal Mark of subject[2] for student[1]=18
Enter 3 internal Assessment mark for subject[1]=81 95 89
Internal Mark of subject[2] for student[1]=17
Enter 3 internal assessment mark for subject[2]=90 91 94
Internal Mark of subject[2] for student[1]=16
Enter 3 internal Assessment mark for subject[1]=89 67 84
Internal Mark of subject[2] for student[1]=16
Result:
Aim:
To write a C program to create a telephone directory using random access file.
Algorithm:
1. Start
2. Create a structure for telephone directory
3. To insert a record in random access file create file pointer and get necessary details
from user. Using seek command move file pointer position to the desired location
and perform file write operation.
4. To update a record in a random access file create a file pointer and get necessary
details from user. Using seek command move file pointer position to the desired
location and perform file write operation.
5. Delete a record get the record number from user. If it is matched in the record
number in the file then writes blank record in that location.
6. Stop
Program:
#include<stdio.h>
struct telDirectory
{
int recno;
char lastName[15];
char firstName[15];
int telno;
};
int enterChoice(void);
void textFile(FILE*);
void updateRecord(FILE*);
void newRecord(FILE*);
void deleteRecord(FILE*);
void main()
{
FILE *cfptr;
int choice;
clrscr();
printf(“Enter your choice”);
while((choice=enterChoice())!=6)
{
switch(choice)
{
case 1:
textFile(cfptr) ;
break;
case 2:
newRecord(cfptr);
break;
case 3:
updateRecord(cfptr);
break;
case 4:
deleteRecord(cfptr);
break;
case 5:
printf(“\nTelephone Diectory\n”);
fp=fopen(“directory.txt”,”r”);
rewind(fp);
while(fread(&client,sizeof(client),1,fp))
printf(“%d\t%s\t%s\t%d\n”,client.recno,client.lastName,client.first
Name,client.telno);
break;
}
}
fclose(cfptr);
getch();
}
void textFile(FILE *readPtr)
{
FILE *writePtr;
struct telDirectory client={0,””,””,0};
if((writePtr=fopen(“directory.txt”,”w”))==NULL)
printf(“File could not be opened.\n”);
else
{
rewind(readPtr);
fprintf(writePtr,”%d%s%s%d\n”,”Record No”,”LastName”,”FirstName”,”telno”);
while(!feof(readPtr))
{
fread(&client,sizeof(struct telDirectory),1,readPtr);
if(client.recno!=0)
fprintf(writePtr,”%d%s%s%d\n”,client.recno,client.lastName,client.firstNa
me,client.telno);
}
fclose(writePtr);
}
}
void updateRecord(FILE *fPtr)
{
int rno;
struct telDirectory client={0,“”,””,0};
printf(“Enter record number to update(1-100):”);
scanf(“%d”,&rno);
fseek(fPtr,(rno-1)*sizeof(struct telDirectory),SEEK_SET);
fread(&client,sizeof(struct telDirectory),1,fPtr);
if(client.recno==0)
printf(“Record % has no information.\n”,rno);
else
{
printf(“\n%d%s%s%d\n\n”,client.recno,client.lastName,client.firstName,client.telno);
printf(“Enter first Name to change: ”);
scanf(“%s”,client.firstName);
printf(“Enter lastName to change: ”);
scanf(“%s”,client.lastName);
printf(“Enter telephone number to change: ”);
scanf(“%s”,client.telno);
printf(“%d%s%s%d \n”,client.recno,client.lastName,client.firstName,client.telno);
fseek(fPtr,(rno-1)*sizeof(struct telDirectory),SEEK_SET);
fwirte(&client,sizeof(struct telDirectory),1,fPtr);
}
}
void deleteRecord(FILE *fPtr)
{
struct telDirectory client,blankClient={0,””,””,0};
int telNo;
printf(“Enter record number to delete (1-100):”);
scanf(“%d”,telNo);
fseek(&client,sizeof(strct telDirectory),1,fPtr);
fread(&client,sizeof(struct telDirectory),1,fPtr);
if(client.recno==0)
printf(“Directory %d does not exist.\n”,telNo);
else
{
fseek(fPtr,(telN0-1)*sizeof(struct telDirectory),SEEK_SET);
fwrite(&blankClient,sizeof(struct telDirectory),1,fPtr);
}
}
void newRecord(File *fPtr)
{
struct telDirectory client={0,””,””,0};
int telNo;
printf(“Enter new record number(1-100): ”);
scanf(“%d”,&telNo);
fseek(fPtr,(telNo-1)*sizeof(struct telDirectory),SEEK_SET);
fread(&clent,sizeof(struct telDirectory),1,fPtr);
if(client.recno!=0)
printf(“Record %d already contains information.\n”,client.recno);
else
{
printf(“Enter lastName,firstName.telno ?\n”);
scanf(“%s%s%d”,&client.lastName,&client.firstName,&client.telno);
client.recno=telNo;
fseek(fPtr,(client.recno-1)*sizeof(struct telDirectory),SEEK_SET);
fwrite(&client,sizeof(struct telDirectory),1,fPtr);
}
}
int enterChoice(void)
{
int choice
printf(“\nEnter your choice\n1 – store a formatted text file of directory called\n
directory.txt for printing\n 2 – Add new\n3 – Update\n 4 – Delete\n 5 – Display\n 6 – Exit?\n”);
scanf(“%d”,&choice) ;
return choice;
}
Sample Output:
Enter your choice
1 – Stroe a formatted text file of directory called directory.txt for printing
2 – Add new
3 – Update
4 – Delete
5 – Display
6 – Exit?
2
Result
Aim:
To write a C program count the number of account holders whose balance in less than
minimum balance using sequential access file.
Algorithm:
1. Start
2. Read no. of records
3. Read information’s for account holders
4. Store it in the file
5. Display all the details one by one
6. Read minimum balance value
7. If balance<minibalance then increment the count value
8. Print count value
9. Stop
Program:
#include<stdio.h>
typedef struct.
{
int accno;
char name[25];
int balance;
}STD;
void main()
{
int i,n,minbalance,opn;
int count=0;
FILE *fp;
clrscr();
printf(“How many records ?”);
scanf(“%d”,&n);
fp=fopen(“account.dat”,”w”);
for(i=0;i<n;i++)
{
printf(“Read the info for account holder:%d (Account
number,name,balance)\n”,i+1);
scanf(“%d%s%d”,&s.accno,&s.name,&s.balance);
fwrite(&s,sizeof(s),1,fp);
}
fclose(fp);
fp=fopen(“account.dat”,”r”);
do
{
printf(“\nPress 1-Display\t2-Search\t3-Exit\t your options?”);
scanf(“%d”,&opn);
switch(opn)
{
case 1:
printf(“\nAccount Records in the File\n”);
rewind(fp);
while(fread(&s,sizeof(s),1,fp))
printf(“%d\t%s\t%d\n”,s.accno,s.name,s.balance);
break;
case 2:
printf(“Read the minimum balance of the customer to be
searched?”) ;
scanf(“%d”,minbalance);
rewind(fp);
while(fread(&s,sizeof(s),1,fp))
{
if(s.balance<=minbalance)
count++;
}
printf(“the number of minimum balance accounts =%d”,count);
case 3:
printf(“Exit! Press a key...”);
getch();
exit();break;
default:printf(“Invalid option!!!Try again later...\n”)
break;
}
}
while(opn!=3);
fclose(fp);
}
Sample output:
How many records: 3
Read the info for account holder: 1(Account number,name,balance)
1001
Sugitha
7000
Read the info for account holder: 2(Account number,name,balance)
1002
Raj
500
Read the info for account holder: 3(Account number,name,balance)
1003
Varsha
700
Press 1 – Display 2 – Search 3 – Exit your option? 2
Read the minimum balance of the customer to be searched? 1000
The number of minimum balance accounts = 2
Press 1 – Display 2 – Search 3 – Exit your option? 3
Exit!!! Press a key...
Result:
Aim:
To write a C program to simulate railway reservation system using following modules
• Booking
• Available Checking
• Cancellation
• Prepare chart
Program
#include<stdlib.h>
#include<stdio.h>
#include<ctype.h>
#include<dos.h>
#include<key.h>
#include<mouse.h>
#include<vid_mem.h>
#define UP 72
#define DN 80
char s2[20],s1[20];
int k,z,l;
float t;
void concession();
void p();
void mmts();
void natrail();
void details();
void main()
{
int i,j,n;
clrscr();
bgcolor(16);
rectangle(2,2,74,20,112);
rectangle(3,57,15,0,96);
rectangle(4,57,15,0,112);
rectangle(5,57,15,0,32);
pstr("WELCOME TO SOUTH CENTRAL RAILWAYS!!!",3,19,32);
pstr("GOVT. OF INDIA *",4,32,112);
printf("\n\n\n\n\n\n\n\t\tWE PROVIDE YOU THE FACILITY TO TRAVEL
IN\n\n\n\t\t\t*********************\n\t\t\t*1.MMTS\n\n\t\t\t*2.NATIONAL
RAILWAYS\n\n\t\t\t*********************\n");
printf("\n\n\t\tEnter Your Choice\n\n\t");
scanf("%d",&n);
switch(n)
{
case 1:
mmts();
break;
case 2:
natrail();
break;
default:
printf("\nPlease Enter The Right Choice\n");
break;
}
getch();
}
void mmts()
{
int z,c,p,i,j,t,total=0,m,u,n,v;
char s1[20],ch,q;
clrscr();
bgcolor(16);
rectangle(1,2,74,22,112);
printf("\n\tEnter The Date\n\t");
gets(s1);
gets(s1);
printf("\t1.Hayat
nagar\n\t2.Malakpet\n\t3.Chandrayangutta\n\t4.Faluknuma\n\t5.Kacheguda\n\t6.Vidyanagar\n\t7.
Nampally\n\t8.Lakdikapool\n\t");
pstr("Do you want to go via ^HI-TECH CITY or ^AMEERPET",11,15,32);
printf("\n\tEnter the blinking character\n\t");
scanf("%c",&ch);
if(ch=='h')
{
printf("\t10.Banjarahills\n\t11.VIT Park\n\t12.Hitech
City\n\t13.Kondapur\n\t14.BHEL\n");
}
else
printf("\n\t\t10.Khairtabad\n\t\t11.S.R.nagar\n\t\t12.Bharatnagar\n\t\t13.Lingampally\n\t\t1
4.BHEL\n");
/*_____________-printing of ticket-________________*/
clrscr();
bgcolor(16);
rectangle(1,4,70,22,112);
printf("\n\n\t\t*************************************************\n");
printf("\t\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t\t\t\tMMTS\n");
printf("\t\tdate:");
puts(s1);
printf("\t\tticket no: 0%d",z);
printf("\t\tFrom: %d To: %d",i,j);
printf("\n\t\tNO OF ADULTS : %d\n",v);
printf("\n\t\tNO OF CHILDREN(0-5 years) : %d\n",m);
printf("\n\t\ttime taken will be %d minutes\n",n*5);
printf("\t\tthe total no of kms are %d\n",n*7);
printf("\t\tthe charge for you is Rs. %d/-\n",c);
printf("\t\tthe charge for your children/child is Rs. %d/-\n",p);
printf("\t\tTHE TOTAL CHARGE IS %d/-\n",total);
printf("\t\t**PLEASE PROVIDE PROOF OF SENIOR CITIZEN(if any)**\n");
printf("\t\t`note:please refer the from & to numbers back ");
printf("\n\t\t side of the ticket'");
printf("\n\n\t\t\t\t*$*HAPPY JOURNEY*$*\n\n");
printf("\t\t**************************************************\n");
printf("\n\t\tpress any key to continue.......");
scanf("%c",q);
clrscr();
bgcolor(16);
rectangle(2,2,74,20,112);
rectangle(6,12,54,8,BLK);
rectangle(5,10,54,8,32);
pstr("YOUR TICKET IS CONFIRMED!!!",6,25,32);
gotoxy(23,17);
rectangle(18,11,55,0,96);
rectangle(19,11,55,0,112);
printf("THANKS FOR UTILISING THIS FACILITY\n");
printf("\t\t\t --SOUTH CENTRAL RAILWAYS-- ");
pstr(" *",19,11,112);
rectangle(20,11,55,0,32);
}
if(t==2)
{
clrscr();
bgcolor(112);
rectangle(6,12,54,8,BLK);
rectangle(5,10,54,8,32);
pstr("ABORTED BY THE USER!!!",6,25,32);
gotoxy(23,17);
rectangle(18,11,55,0,96);
rectangle(19,11,55,0,112);
printf("THANKS FOR UTILISING THIS FACILITY\n");
printf("\t\t\t --SOUTH CENTRAL RAILWAYS-- ");
pstr(" *",19,11,112);
rectangle(20,11,55,0,32);
}
}
void natrail()
{
int q,i,j,m,n;
char f,d,ch,e;
clrscr();
bgcolor(16);
rectangle(2,2,74,20,112);
printf("\n\n\n\n\tenter the date of journey:-");
rectangle(4,35,30,0,15);gotoxy(36,5);
gets(s1);
gets(s1);
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
pstr("TR NO. TRN NAME ORIGIN DEP DESTNATN ARR
",3,3,32);
printf("\n\n\n\n
__________________________________________________________________________");
printf(" \n 8563 PRASANTHI EXP VISHAKAPATNAM 10:45 BANGALORE CY JN
10:00\n");
printf(" 1019 KONARK EXPRESS BEGAMPET 07:15 VISHAKAPATNAM
20:55\n");
printf(" 7008 GODAVARI EXP HYDERABAD DECAN 17:15 VISHAKAPATNAM
06:50\n");
printf(" 7016 VISAKHA EXP SECUNDERABAD JN 17:00 VISHAKAPATNAM
07:10\n");
printf(" 2308 BKN HWH SUPFAST BIKANER JN 18:30 HOWRAH JN
04:20\n");
printf(" 2330 A P SMPRK KRNTI DELHI 18:45 HYDERABAD 17:45\n");
printf(" 2430 BANGLORE RJDHNI H NIZAMUDDIN 20:50 BANGALORE CY JN
07:25\n");
printf(" 2952 MUMBAI RAJDHANI NEW DELHI 16:00 MUMBAI CENTRAL
08:35\n");
printf(" 4008 SADHBHAWNA EXP DELHI 16:45 MUZAFFARPUR JN
17:30\n");
printf(" 6507 JU BANGLORE EXP JODHPUR JN 05:30 BANGALORE CY JN
04:00\n");
printf("\n\n\t***please note the code carefully***\n");
printf("\n\tenter the train code correctly as mentioned as above\n");
printf("\t");
scanf("%d",&n);
randomize();
z=random(500);
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
switch(n)
{
case 8563:
printf(" \n\n\n\n 8563 PRASANTHI EXP VISHAKAPATNAM 10:45 BANGALORE
CY JN 10:00\n");
printf("\n\n\tclass:\n\t1.FIRST AC\n\t2.SECOND AC \n\t3.2 CHAIR AC CAR\n\t4.S/L FIRST
CLASS \n\t5.S/L SECOND CLASS\n\t6.GENERAL\n");
printf("\n\tenter ur choice: ");
scanf("%d",&q);
switch(q)
{
case 1:
clrscr();
details();
t=399.0;
printf("\n\ttotal charge is Rs.399/-per head");
printf("\n\tDO YOU WANT TO AVAIL ANY CONNCESSION\n\n\n\n");
d='y';
if(d=='y')
{
concession();
}
messagebox(" CONFIRM THE TICKET",10,19,'N',"NULL");
m=response(10,19);
if(m==1)
{
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:8563\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: PRASANTHI
EXP\n\t ");printf("Origin: VISHAKAPATNAM dep:10:45\n\t"); printf(" Dest:BANGALORE
CY JN arr:10:00\n");
p();
}
if(m==2)
{
clrscr();
bgcolor(112);
rectangle(6,12,54,8,BLK);
rectangle(5,10,54,8,32);
pstr("ABORTED BY THE USER!!!",6,25,32);
gotoxy(23,17);
rectangle(18,11,55,0,96);
rectangle(19,11,55,0,112);
printf("THANKS FOR UTILISING THIS FACILITY\n");
printf("\t\t\t --SOUTH CENTRAL RAILWAYS-- ");
pstr(" *",19,11,112);
rectangle(20,11,55,0,32);
}
}
break;
case 2:
clrscr();
details();
t=359.0;
printf("\n\n\ttotal charge is Rs.359/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
//scanf("%c",&d);
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf("\tTrain no:8563\t\t\t\tTicket No:0%d\n\t",z);printf(" Train name: PRASANTHI
EXP\n\t");printf("Origin:VISHAKAPATNAM Dep:10:45\n\t");printf("Dest: BANGALORE CY
JN Arr:10:00\n");
p();}
break;
case 3:
clrscr();
details();
t=249.0;
printf("\n\n\ttotal charge is Rs.249/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
//scanf("%c",&d);
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:8563\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: PRASANTHI EXP\n\t
");printf("Origin: VISHAKAPATNAM dep:10:45\n\t"); printf(" Dest:BANGALORE CY JN
arr:10:00\n");
p();}
break;
case 4:
clrscr();
details();
t=199.0;
case 5:
clrscr();
details();
t=159.0;
printf("\n\n\ttotal charge is Rs.159/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
//scanf("%c",&d);
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:8563\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: PRASANTHI EXP\n\t
");printf("Origin: VISHAKAPATNAM dep:10:45\n\t"); printf(" Dest:BANGALORE CY JN
arr:10:00\n");
p();}
break;
}break;
case 1019:
printf(" \n\n\n\n 1019 KONARK EXPRESS BEGAMPET 07:15
VISHAKAPATNAM 20:55\n");
printf("\n\n\tclass:\n\t1.FIRST AC\n\t2.SECOND AC \n\t3.2 CHAIR AC
CAR\n\t4.S/L FIRST CLASS \n\t5.S/L SECOND CLASS\n\t6.GENERAL\n");
case 3:
clrscr();
details();
t=294.0;
printf("\n\ttotal charge is Rs.294/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
//scanf("%c",&d);
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:1019\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: KONARK EXPRESS\n\t
");printf("Origin: BEGUMPET dep:07:15\n\t"); printf(" Dest:VISHAKAPATNAM
arr:20:55\n");
p();}break;
case 4:
clrscr();
details();
t=254.0;
printf("\n\ttotal charge is Rs.254/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
//scanf("%c",&d);
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(48);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:1019\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: KONARK EXPRESS\n\t
");printf("Origin: BEGUMPET dep:07:15\n\t"); printf(" Dest:VISHAKAPATNAM
arr:20:55\n");
p();}break;
case 5:
clrscr();
details();
t=199.0;
printf("\n\ttotal charge is Rs.194/-per head");
case 2:
clrscr();
details();
t=399.0;
printf("\n\ttotal charge is Rs.399/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
//scanf("%c",&d);
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:7008\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: GODAVARI
EXPRESS\n\t ");printf("Origin: HYDERABAD DECCAN dep:17:15\n\t"); printf("
Dest:VISHAKAPATNAM arr:06:50\n");
p();}break;
case 3:
clrscr();
details();
t=350.0;
printf("\n\n\ttotal charge is Rs.350/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
//scanf("%c",&d);
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:7008\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: GODAVARI
EXPRESS\n\t ");printf("Origin: HYDERABAD DECCAN dep:17:15\n\t"); printf("
Dest:VISHAKAPATNAM arr:06:50\n");
p();}break;
case 4:
clrscr();
details();
t=250.0;
}break;
case 7016:
printf("\n\n\n\n 7016 VISAKHA EXP
SECUNDERABAD JN 17:00 VISHAKAPATNAM 07:10\n");
printf("\n\n\tclass:\n\t1.FIRST AC\n\t2.SECOND AC \n\t3.2
CHAIR AC CAR\n\t4.S/L FIRST CLASS \n\t5.S/L SECOND CLASS\n\t6.GENERAL\n");
printf("\n enter ur choice: ");
scanf("%d",&q);
switch(q)
{
case 1:
clrscr();
details();
t=410.0;
printf("\n\n\ttotal charge is Rs.410/-per head");
printf("\n\tIS THERE ANY
CONCESSION(Y/N)\n\n\n\n");
d='y';
//scanf("%c",&d);
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:7016\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: VISHAKA EXP\n\t
");printf("Origin: SECUNDERABAD JN dep:17:00\n\t"); printf("
Dest:VISHAKAPATNAM arr:07:10\n");
p();}break;
case 2:
clrscr();
details();
t=390.0;
printf("\n\n\ttotal charge is Rs.390/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:7016\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: VISHAKA EXP\n\t
");printf("Origin: SECUNDERABAD JN dep:17:00\n\t"); printf("
Dest:VISHAKAPATNAM arr:07:10\n");
p();}break;
case 3:
clrscr();
details();
t=310.0;
printf("\n\n\ttotal charge is Rs.310/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:7016\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: VISHAKA EXP\n\t
");printf("Origin: SECUNDERABAD JN dep:17:00\n\t"); printf("
Dest:VISHAKAPATNAM arr:07:10\n");
p();}break;
case 4:
clrscr();
details();
t=250.0;
printf("\n\n\ttotal charge is Rs.250/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
//scanf("%c",&d);
if(d=='y')
{concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:7016\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: VISHAKA EXP\n\t
");printf("Origin: SECUNDERABAD JN dep:17:00\n\t"); printf("
Dest:VISHAKAPATNAM arr:07:10\n");
p();}break;
case 5:
clrscr();
details();
t=190.0;
case 2:
clrscr();
details();
t=375.0;
printf("\n\n\ttotal charge is Rs.375/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:2308A\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: BKN HWH
SUPFAST\n\t ");printf("Origin: BIKANER JN dep:18:30\n\t"); printf(" Dest:HOWRAH
arr:04:20\n");
p();} break;
case 3:
clrscr();
details();
t=325.0;
printf("\n\n\ttotal charge is Rs.325/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:2308A\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: BKN HWH
SUPFAST\n\t ");printf("Origin: BIKANER JN dep:18:30\n\t"); printf(" Dest:HOWRAH
arr:04:20\n");
p();} break;
case 4:
clrscr();
details();
t=255.0;
case 5:
clrscr();
details();
t=195.0;
printf("\n\n\ttotal charge is Rs.195/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
//scanf("%c",&d);
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:2308A\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: BKN HWH
SUPFAST\n\t ");printf("Origin: BIKANER JN dep:18:30\n\t"); printf(" Dest:HOWRAH
arr:04:20\n");
p();}
break;
}break;
case 2330:
printf("\n\n\n\n 2330 A P SMPRK KRNTI DELHI 18:45 HYDERABAD
17:45\n");
case 3:
clrscr();
details();
t=290.0;
printf("\n\n\ttotal charge is Rs.290/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:2330\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: A P SMPRK KRNTI\n\t
");printf("Origin: DELHI dep:18:40\n\t"); printf(" Dest:HYDERABAD arr:17:45\n");
p();} break;
case 4:
clrscr();
details();
t=250.0;
printf("\n\n\ttotal charge is Rs.250/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:2330\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: A P SMPRK KRNTI\n\t
");printf("Origin: DELHI dep:18:40\n\t"); printf(" Dest:HYDERABAD arr:17:45\n");
p();}
break;
case 5:
clrscr();
details();
t=190.0;
printf("\n\n\ttotal charge is Rs.190/-per head");
}break;
case 2430:
printf("\n\n\n\n 2430 BANGLORE RJDHNI H NIZAMUDDIN 20:50 BANGALORE CY JN
07:25\n");
printf("\n\n\tclass:\n\t1.FIRST AC\n\t2.SECOND AC \n\t3.2 CHAIR AC CAR\n\t4.S/L FIRST
CLASS \n\t5.S/L SECOND CLASS\n\t6.GENERAL\n");
printf("\n enter ur choice: ");
scanf("%d",&q);
switch(q)
{
case 1:
clrscr();
details();
t=654.0;
printf("\n\n\ttotal charge is Rs.654/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:2430\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: BANGALORE RJDHNI
EXP\n\t ");printf("Origin: H NIZAMUDDIN dep:20:50\n\t"); printf(" Dest:BANGALORE
arr:07:25\n");
p();}
break;
case 2:
clrscr();
details();
t=554.0;
printf("\n\n\ttotal charge is Rs.554/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:2430\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: BANGALORE RJDHNI
EXP\n\t ");printf("Origin: H NIZAMUDDIN dep:20:50\n\t"); printf(" Dest:BANGALORE
arr:07:25\n");
p();}
break;
case 3:
clrscr();
details();
t=454.0;
printf("\n\n\ttotal charge is Rs.454/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:2430\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: BANGALORE RJDHNI
EXP\n\t ");printf("Origin: H NIZAMUDDIN dep:20:50\n\t"); printf(" Dest:BANGALORE
arr:07:25\n");
p();}
break;
case 4:
clrscr();
details();
t=354.0;
printf("\n\n\ttotal charge is Rs.354/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:2430\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: BANGALORE RJDHNI
EXP\n\t ");printf("Origin: H NIZAMUDDIN dep:20:50\n\t"); printf(" Dest:BANGALORE
arr:07:25\n");
p();}
break;
case 5:
clrscr();
details();
t=254.0;
printf("\n\n\ttotal charge is Rs.254/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:2430\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: BANGALORE RJDHNI
EXP\n\t ");printf("Origin: H NIZAMUDDIN dep:20:50\n\t"); printf(" Dest:BANGALORE
arr:07:25\n");
p();}
break;
}break;
case 2952:
case 3:
clrscr();
details();
t=350.0;
printf("\n\n\ttotal charge is Rs.350/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:2952\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: MUMBAI RAJDHANI
EXP\n\t ");printf("Origin: NEW DELHI dep:16:00\n\t"); printf(" Dest:MUMBAI
arr:08:35\n");
p();}
break;
case 4:
clrscr();
details();
t=250.0;
printf("\n\n\ttotal charge is Rs.250/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
case 5:
clrscr();
details();
t=150.0;
printf("\n\n\ttotal charge is Rs.150/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:2952\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: MUMBAI RAJDHANI
EXP\n\t ");printf("Origin: NEW DELHI dep:16:00\n\t"); printf(" Dest:MUMBAI
arr:08:35\n");
p();}
break;
}break;
case 4008:
printf("\n\n\n\n 4008 SADHBHAWNA EXP DELHI 16:45 MUZAFFARPUR JN
17:30\n");
printf("\n\n\tclass:\n\t1.FIRST AC\n\t2.SECOND AC \n\t3.2 CHAIR AC CAR\n\t4.S/L FIRST
CLASS \n\t5.S/L SECOND CLASS\n\t6.GENERAL\n");
printf("\n enter ur choice: ");
scanf("%d",&q);
switch(q)
{
case 1:
clrscr();
details();
t=368.0;
printf("\n\n\ttotal charge is Rs.368/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:4008\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: SADHBHAWNA
EXP\n\t ");printf("Origin: NEW DELHI dep:16:45\n\t"); printf(" Dest:MUZAFFARPUR
arr:17:30\n");
p();}
break;
case 2:
clrscr();
details();
t=318.0;
printf("\n\n\ttotal charge is Rs.368/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:4008\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: SADHBHAWNA
EXP\n\t ");printf("Origin: NEW DELHI dep:16:45\n\t"); printf(" Dest:MUZAFFARPUR
arr:17:30\n");
p();}
break;
case 3:
clrscr();
details();
t=298.0;
printf("\n\n\ttotal charge is Rs.298/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:4008\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: SADHBHAWNA
EXP\n\t ");printf("Origin: NEW DELHI dep:16:45\n\t"); printf(" Dest:MUZAFFARPUR
arr:17:30\n");
p();}
break;
case 4:
clrscr();
details();
t=218.0;
printf("\n\n\ttotal charge is Rs.218/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:4008\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: SADHBHAWNA
EXP\n\t ");printf("Origin: NEW DELHI dep:16:45\n\t"); printf(" Dest:MUZAFFARPUR
arr:17:30\n");
p();}
break;
case 5:
clrscr();
details();
t=168.0;
printf("\n\n\ttotal charge is Rs.168/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:4008\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: SADHBHAWNA
EXP\n\t ");printf("Origin: NEW DELHI dep:16:45\n\t"); printf(" Dest:MUZAFFARPUR
arr:17:30\n");
p();}
break;
}break;
case 6507:
printf("\n\n\n\n 6507 JU BANGLORE EXP JODHPUR JN 05:30 BANGALORE CY JN
04:00\n");
printf("\n\n\tclass:\n\t1.FIRST AC\n\t2.SECOND AC \n\t3.2 CHAIR AC CAR\n\t4.S/L FIRST
CLASS \n\t5.S/L SECOND CLASS\n\t6.GENERAL\n");
printf("\n enter ur choice: ");
scanf("%d",&q);
switch(q)
{
case 1:
clrscr();
details();
t=400.0;
printf("\n\n\ttotal charge is Rs.400/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:6507\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: JU BANGALORE
EXP\n\t ");printf("Origin: JODHPUR dep:05:30\n\t"); printf(" Dest:BANGALORE
arr:04:00\n");
p();}
break;
case 2:
clrscr();
details();
t=350.0;
printf("\n\n\ttotal charge is Rs.350/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:6507\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: JU BANGALORE
EXP\n\t ");printf("Origin: JODHPUR dep:05:30\n\t"); printf(" Dest:BANGALORE
arr:04:00\n");
p();}
break;
case 3:
clrscr();
details();
t=300.0;
printf("\n\n\ttotal charge is Rs.300/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:6507\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: JU BANGALORE
EXP\n\t ");printf("Origin: JODHPUR dep:05:30\n\t"); printf(" Dest:BANGALORE
arr:04:00\n");
p();}
break;
case 4:
clrscr();
details();
t=250.0;
printf("\n\n\ttotal charge is Rs.250/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:6507\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: JU BANGALORE
EXP\n\t ");printf("Origin: JODHPUR dep:05:30\n\t"); printf(" Dest:BANGALORE
arr:04:00\n");
p();
}
break;
case 5:
clrscr();
details();
t=200.0;
printf("\n\n\ttotal charge is Rs.200/-per head");
printf("\n\tIS THERE ANY CONCESSION(Y/N)\n\n\n\n");
d='y';
if(d=='y')
{
concession();}
f='y';
/*________________printing of ticket__________________________*/
if(f=='y')
{
clrscr();
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\t**********************************************\n");
printf("\t\t SOUTH CENTRAL RAILWAYS\n");
printf("\t\t Government of INDIA\n\n");
printf(" \tTrain no:6507\t\t\t\tTicket No:0%d\n\t",z);printf("Train name: JU BANGALORE
EXP\n\t ");printf("Origin: JODHPUR dep:05:30\n\t"); printf(" Dest:BANGALORE
arr:04:00\n");
p();
}
break;
}break;
}
}
/*______________________________________collection of
details___________________________________________*/
void details()
{
bgcolor(16);
rectangle(2,2,75,20,112);
printf("\n\n\n\n\t");
pstr("Enter the NAME :",4,6,32); rectangle(4,32,30,0,15);gotoxy(33,5);
fflush(stdin);
gets(s2);
pstr("Enter the AGE :",6,6,32);rectangle(6,32,30,0,15);gotoxy(33,7);
scanf("%d",&k);
}
/*___________________________printing of ticket___________________________________*/
void p()
{
printf("\tdate of journey:");
puts(s1);
printf("\n\t NAME: ");
puts(s2);
printf("\n\t AGE : %d\n",k);
printf("\n\t**PLEASE PROVIDE PROOF OF CONCESSION(if any)**\n");
//puts(l);
printf("\n\tTHE TOTAL CHARGE IS %f/-",t);
printf("\n\n\n\t\t\t*$*HAPPY JOURNEY*$*\n");
printf("\t***********************************************\n");
}
/*_____________________________info about
concessions________________________________*/
void concession()
{
printf("\t1.BLIND CONCESSION-75%\n ");
printf("\t2.DEAF & DUMB CONCESSION50%\n");
printf("\t3.DOCTOR'S CONCESSION-10%\n");
printf("\t4.HANDICAPPED CONCESSION-75%\n");
printf("\t5.KISAN CONCESSION-25%\n");
printf("\t6.PUBLIC EXAMINATION CONCESSION-50%\n");
printf("\t7.RESEARCH SCHOLAR CONCESSION-50%\n");
printf("\t8.SENIOR CITIZEN CONCESSION-30%\n");
printf("\t9.WAR WIDOW CONCESSION-75%\n\n\n");
pstr("enter ur choice(ONLY IF PROOFS ARE AVAILABLE)",40,15,64);
scanf("%d",&l);
switch(l)
{
case 1:t=t*25/100;break;
case 2:t=t*50/100;break;
case 3:t=t*90/100;break;
case 4:t=t*25/100;break;
case 5:t=t*75/100;break;
case 6:t=t*50/100;break;
case 7:t=t*50/100;break;
case 8:t=t*70/100;break;
case 9:t=t*25/100;break;
}
}
message()
{
}
Output
Result: