Codechef Problems: Selling Sandwiches (SANDWSHOP)

 Problem Statement

Chef sells sandwiches for a living. Each sandwich is sold for A rupees.

Chef also needs to buy the ingredients to make a sandwich. The sandwich buns cost B rupees, and the vegetables cost C rupees. Let us assume that there are no other costs for Chef right now.

What is the profit Chef makes in selling one sandwich? It may be possible that the answer is negative to indicate that Chef makes a loss instead.

Input Format

  • The first and only line of input contains 3 integers - A,B and C.

Output Format

For each test case, output on a new line the profit or loss Chef makes in selling one sandwich.

Constraints

  • 100A1000
  • 40B200
  • 40C200

Solution: 

given, 
    A : Income by Selling Sandwiches 
    B : Cost of Sandwich Buns
    C : Cost of Vegetables

So, Final Profit = Income - Cost  =  A - ( B + C ) 

Code Solution: 

#include <bits/stdc++.h>
using namespace std;

int main() {
    int a, b, c; 
    cin >> a >> b >> c; 
    
    cout << a - b - c << endl; 
    return 0; 
}

Comments

Popular posts from this blog

Codechef Problems: Triangles (TRIANGLE7)

Codechef problems : New Year Resolution (NYRES)