Answer:
#include<iostream>
using namespace std;
/* main is a function without a parameters which returns an int value*/
int main( )
{
/* declare int data type for numeric values initialize candyBar and gumBall */
int coupons, cabdyBr=10,gumall=3;
int candyBarAmount,gumBallAmount,remainder;
/* cout is used to show the message to user cin to read user input from keyboard and sets the value to coupon */
cout<<"Enter the number of coupons"\t";
cin>>coupons;
/* First check coupons with cabdyBar */
if (coupons >= candyBar)
{
candyBarAmount=coupons/candyBar;
remainder=coupons-(candyBarAmount*10);
}
else
{
candyBarAmount=0;
}
/* check remaining value with gumBall */
if (remainder<<candyBar && remainder>=gumBall)
{
gumBallAmount=remainder/gumball;
}
else
{
gumBallAmount=0;
}
/* show thw required output to the user */
cout<<"The number of Candy bars is "<< candyBarAmount <<endl;
cout<<"The number of gumballs is "<<gumballAmount <<endl;
/* The program ends and return 0 as the functions value */
return 0;
}
OUTPUT
Enter the number of coupons: 23
The number of candy bars = 2
The number of gumballs = 1