Created
November 1, 2020 11:48
-
-
Save swetarajbhar/bba4fe5be7c371a4022265029ca51667 to your computer and use it in GitHub Desktop.
Chocolate and Wrapper Puzzle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
using namespace std; | |
int totalchoc(int money,int price,int wrap) | |
{ | |
if(money < price) | |
{ | |
return 0; | |
} | |
int choc=money/price; | |
choc = choc+(choc-1)/(wrap-1); | |
return choc; | |
} | |
int main() | |
{ | |
int money,price,wrap; | |
cout<<"Enter Money : "; | |
cin>>money; | |
cout<<"Enter Price Per Chocolate : "; | |
cin>>price; | |
cout<<"Enter Wrapper :"; | |
cin>>wrap; | |
cout<<"Maximum Number of Chocolates = "<<totalchoc(money,price,wrap); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment