Tickets Sold For Charity Event

Tickets Sold For Charity Event



Problem:

HelpIndia, a famous NGO has been selective in identifying events to raise funds for charity. Suzanne is a volunteer from the NGO who was selling tickets to the public for the charity event. She sold 'X' more adult tickets than children tickets and she sold twice as many senior tickets as children tickets. Assume that an adult ticket costs $5, children ticket costs $2 and senior ticket costs $3.

Suzanne made 'Y' dollars from ticket sales. Find the number of adult tickets, children's tickets, and senior tickets sold.

Input Format:

The first input is an integer value X that corresponds to the number of adult tickets more than children's tickets.
The second input is an integer value Y that corresponds to the money in dollars made by Suzanne from ticket sales.

Output Format:

The first line of the output should display the number of children tickets sold.
The second line of the output should display the number of adult tickets sold.
The third line of the output should display the number of senior tickets sold.

Sample Input and Output :
Enter the value of X
10
Enter the value of Y
700
Number of children tickets sold: 50
Number of adult tickets sold: 60
Number of senior tickets sold: 100

Solution:C Code:

#include<stdio.h>
int main()
{
    int x,y,a,b,c;
    printf("Enter the value of X\n");
    scanf("%d",&x);
    printf("Enter the value of Y\n");
    scanf("%d",&y);
    a=(y-(5*x))/13;
    b=x+a;
    c=(2*a);
    printf("Number of children tickets sold : %d\n",a);
    printf("Number of adult tickets sold : %d\n",b);
    printf("Number of senior tickets sold : %d",c);
    return 0;
}

Output:

>Enter the value of X
>10
> Enter the value of Y
> 700
> Number of children tickets sold: 50
>Number of adult tickets sold: 60
>Number of senior tickets sold: 100
 >

Comments