Im trying to have this program continue to run when you enter y or Y at the end or quit when you enter n or N. Everything I try either has it just end or continue to repeat. Any help would be great, thanks!

#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;

double caterCalc(int, double);

int main ()
{
        int quantity;
        double price;
        char c;
        
        while (c == 'y' || 'Y') {
                cout << "How many people are coming: ";
                cin >> quantity;
                cout << "What is the price per person: ";
                cin >> price;
                cout << "The total price is: $"<< caterCalc(quantity, price);
                cout << "\n\nDo you want to run this again? (y/n)";
                cin >> c;
        if (c == 'n' || 'N') {
                break;
        }
        }

        cin.get();
        return 0;
}

double caterCalc(int quantity, double price)
{
        double total = quantity*price;
        return total;
}

I have both of those in there but it just ends the program no matter what I type.

I just woke up, so I didn't see that there is some logical mistake in there. The while condition is always false because c is unassigned and it does not equal to 'Y' or 'y'. Try do while instead.

This question has already been answered. Start a new discussion instead.