Saturday, August 18, 2018

CALCULATING SP

  • Problem Description

    A man buys a cycle for Rs. a and sells it at a loss of b%. What is the selling price of the cycle?
    Write a C program to compute the selling price.
    Input Format:
    The first input is an integer which corresponds to a. The second input is an integer which corresponds to b.
  • CODING ARENA::
  • #include<stdio.h>
    int main()
    {
      int a,b;
      float loss,tot;
      scanf("%d%d",&a,&b);
      if(a==0)
      {
        printf("%d",a);
      }
      else
      {
      loss=a*(b*0.01);
      tot=a-loss;
      printf("The selling price of the cycle is Rs=%.2f",tot);
      }
      return 0;
    }
  • Test Case 1

    Input (stdin)
    1400
    
    15
    
    
    Expected Output
    The selling price of the cycle is Rs=1190.00
  • Test Case 2

    Input (stdin)
    0
    
    
    Expected Output
    0

No comments:

Post a Comment