Combo Meal

A fast-food chain menu is selling a burger, a can of soda, and a combo meal containing a burger and a can of soda, at prices known to you.

They have chosen the selling price for each item by first determining the total cost of making the individual items and then adding a fixed value to it, representing their profit. Assume that the cost of making a regular burger is fixed and the cost of making a regular soda is fixed.

Given the price of a burger, a can of soda, and a combo meal on the menu, your task is to compute the fixed profit.

Complete the function named profit which takes in three integers denoting the selling price of a burger, a can of soda, and a combo meal respectively, and returns an integer denoting the fixed profit.

Example:

Input:  b = 6, s = 9, c = 11
Output: 4

Approach

C++

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

int profit(int bint sint c)
{
    return b + s - c;
}

int main()
{

    int b = 6;
    int s = 9;
    int c = 11;

    cout << profit(bsc<< "\n";
    return 0;
}


Read Interview Questions

Exception Handling Interview Questions

DBMS Interview Questions Set -1

DBMS Interview Questions Set -2

SQL Interview Question Set -1

SQL Interview Question Set -2

JPA Interview Questions Set -1

JPA Interview Question Set -2

Hibernate Interview Questions

Spring Boot Interview Questions Set 1

Spring Boot Interview Questions Set 2


No comments:

Post a Comment