Codechef Problems: Cake Discount (DISCOUNT7)

 Problem Statement:


Solution: 

Given, 
    N : number of cakes to be bought 
    100 : Price of a cake
    15%: special discount when N >= 5 

to find: total cost of cakes you paid 

condition 1 : N < 5 (number of cakes bought is less than 5)
output : total cost = N * 100 

condition 2 : N >= 5 (number of cakes bought is more than or equals to 5)
output: total cost = N * 100 - N * 100 * 0.15 

Code Output: 

#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    cin >> n;

    if (n >= 5) {
        cout << n * 85 << endl;
    } else {
        cout << n * 100 << endl;
    }

    return 0;
}

Comments