Saturday, August 18, 2018

PROFIT CALCULATOR

  • Problem Description

    Each Sunday, a newspaper agency sells x copies of a certain newspaper for Rs.a per copy. The cost to the agency of each newspaper is Rs.b . The agency pays a fixed cost for storage, delivery and so on of Rs.100 per Sunday. The newspaper agency wants to calculate the profit obtained on Sundays. Can you please help them out by writing a C program to compute the profit given x, a and b.

    Input Format:
    Input consists of 3 integers --- x, a and b. X is the number of copies sold, a is the cost per copy and b is the cost the agency spends per copy.
  • CODING ARENA::
  • #include <stdio.h>
    int main()
    {
      int x, a, b,c; 
      scanf("%d",&x); 
      scanf("%d",&a); 
      scanf("%d",&b); 
      c=(x*a)-1100; 
      printf("profit=%d",c); 

    return 0;
    }
  • Test Case 1

    Input (stdin)
    1000
    
    2
    
    1
    
    
    Expected Output
    profit=900
  • Test Case 2

    Input (stdin)
    1000
    
    3
    
    1
    
    
    Expected Output
    profit=1900

No comments:

Post a Comment