Code:
#include <stdio.h>
float getUserDetail(char*, float*);
float getDiscount(char, float, float, float*);
float getDetails(char*, float*, float*);
float FPrint(char*, float*, float*, float*);
int main()
{
char name, CH, Std, movie;
float age, RM, Disc, seat, Time;
printf("\t\t\t\tWELCOME TO UniMAP CINEMA!!!");
do
{
getUserDetail(&name, &age);
getDiscount(Std, age, RM, &Disc);
getDetails(&movie, &seat, &Time);
printf("\nDo you like to continue? If yes, press 'Y':");
scanf("%s",&CH);
}
while(CH=='Y'||CH=='y');
FPrint(&movie, &seat, &Time, &Disc);
printf("\n\t\t\tThank you");
return 0;
}
float getUserDetail(char*name, float*age)
{
printf("\nName: ");
scanf("%s", name);
printf("Age: ");
scanf("%f",age);
return (*age);
}
float getDiscount(char Std,float age, float RM, float*Disc)
{
RM == 15;
if (age < 13){
*Disc == ((30/100)*RM);
return (*Disc); }
else if (age < 19){
printf("Are you a student?(Y/N):");
scanf("%s", &Std);
{
if(Std == 'Y'|| Std == 'y'){
*Disc == ((50/100)*RM);
return (*Disc); }
else
*Disc == RM;
return (*Disc); }}
else
*Disc == RM;
return (*Disc);
}
float getDetails(char*movie, float*seat, float*Time)
{
printf("Name of the movie: ");
scanf("%s", &movie);
printf("Number of the seat: ");
scanf("%f", &seat);
printf("Time of the movie: ");
scanf("%f", &Time);
}
float FPrint(char*movie, float*seat, float*Time, float*Disc)
{
printf("\n\t\t\tBooking Successful");
printf("\n\t\tMovie Name:%s", &movie);
printf("\n\t\tSeat Number:%f", &seat);
printf("\n\t\tTime:%f", &Time);
printf("\n\t\tDiscounted Price:RM%s", &Disc);
}
Output:
Name: kaus
Age: 21
Name of the movie: qwerty
Number of the seat: 21
Time of the movie: 2.15
Do you like to continue? If yes, press 'Y':n
Booking Successful
Movie Name:§■e
Seat Number:0.000000
Time:0.000000
Discounted Price:RM
■e
Thank you
--------------------------------
Process exited after 14.19 seconds with return value 0
Press any key to continue . . .
If I put the '*' instead of '&' and the printf part I get this output:
Name: kaus
Age: 21
Name of the movie: qwerty
Number of the seat: 21
Time of the movie: 2.15
Do you like to continue? If yes, press 'Y':n
Booking Successful
Movie Name:(null)
Seat Number:0.000000
Time:0.000000
Discounted Price:RM(null)
Thank you
--------------------------------
Process exited after 12.51 seconds with return value 0
Press any key to continue . . .
What do I do? and please do forgive me for any silly mistakes I might have made.Thank You.
Tried using '*' and '&' but not getting the correct output. Still rusty on the topic of pointers I want it to print out the movie name: time: seat no.: price: