You are on page 1of 5

NAME: Gideon Abhishek K

Reg No:2062627

EXP NO-9
STRUCTURES

Algorithm:
1. Start
2. Initialize structure
3. Read the number of customers to be stored from the user
4. Declare i=1
If i<n
Read the customer details from the user
MV[i].amt= 100 * MV[i].num_of_seats if
MV[i].cust_type=='R' and MV[i].age<10
MV[i].red=MV[i].amt*0.15;
MV[i].final_amt=MV[i].amt-MV[i].red
if MV[i].cust_type=='R' and MV[i].age>=10
MV[i].red=MV[i].amt*0.1;
MV[i].final_amt=MV[i].amt-MV[i].red; if all
the above mentioned condition are false then
MV[i].final_amt=100
repeat steps from 4.1 to 4.5 till I >n
increment i
5. Print the final bill amount
6. Stop
NAME: Gideon Abhishek K
Reg No:2062627

Flowchart:

Flowchart:
NAME: Gideon Abhishek K
Reg No:2062627
NAME: Gideon
Abhishek K Reg
No:2062627

Program:
#include<stdio.h>
struct mov
{
int cust_id, movie_id, date, time, num_of_seats, age, amt;
float red, final_amt; char cust_type;
};
int main()
{
struct mov MV[100];
int n;
printf("\n\t\tMOVIE BOOKING"); printf("\n\n\tEnter the number
of the customers to be stored : "); scanf(" %d",&n); for (int i =1;
i<=n;i++)
{ printf("\n\tEnter Customer %d's Details: - \n",i);
printf("\tEnter the Cust_ID : ");
scanf("%d",&MV[i].cust_id); printf("\tEnter the
Movie_ID : "); scanf("%d",&MV[i].movie_id);
printf("\tEnter the date : ");
scanf("%d",&MV[i].date); printf("\tEnter the
time : "); scanf("%d",&MV[i].time);
printf("\tEnter the cust_type : "); scanf("
%c",&MV[i].cust_type); printf("\tEnter your age
: "); scanf("%d",&MV[i].age); printf("\tEnter the
num_of_seats : ");
scanf("%d",&MV[i].num_of_seats);
MV[i].amt= 100 * MV[i].num_of_seats;
if((MV[i].cust_type=='R') && (MV[i].age<10))
{
MV[i].red=MV[i].amt*0.15;
MV[i].final_amt=MV[i].amt-MV[i].red;
}
else if (MV[i].cust_type=='R' && MV[i].age>=10)
{
MV[i].red=MV[i].amt*0.1;
MV[i].final_amt=MV[i].amt-MV[i].red;
}
else if (MV[i].cust_type=='T' && MV[i].age>10)
{
MV[i].red=MV[i].amt*0.05;
MV[i].final_amt=MV[i].amt-MV[i].red;
}
else
{
MV[i].final_amt=100;
NAME: Gideon
Abhishek K Reg
No:2062627
}
printf("\n\tFinal bill amount for Customer ID [%d] is:%f\n",MV[i].cust_id,MV[i].final_amt);
} return(0);
}

Output:

You might also like