I need an algorithm to be able to calculate cost when there is a sale for buy two get one free
1
Expert's answer
2014-03-13T13:43:40-0400
#include <iostream> #include <cmath>
using namespace std;
int main() { int n = 0; cout <<"Enter number of items please: "; cin >> n; double total = 0, temp = 0; for (int i = 1; i <= n; ++i) { cout << "Enter price of item number " << i << ": "; cin >> temp; if (i % 3) total += temp; }
Comments
Leave a comment