Can someone fix my program, so it can show the largest amount of mcnuggets that "cannot" be purchased?
I wrote this program, but instead of showing the largest possible amount of mcnuggets out of a 6, 9, and 20 pack that cannot be purchased, it shows the all the possible amounts that can be purchased out 150. So can someone fix my program. I know the largest number that cannot be purchased is 43. But I need my program to show this number only, instead of a list of numbers. Thank You
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int a, b, c, n;
int buy = 6*a+9*b+20*c;
for (n=0; n<150; ++n)
{ for (a=0; a<150; ++a)
{
for (b=0; b<150; ++b)
{
for (c=0; c<150; ++c){
buy=6*a+9*b+20*c;
if (buy==n){
cout<<"You can buy "<<buy<<endl;
break;
}
}//for c
if (buy==n){