Thursday, September 13, 2018

CALCULATING PERCENTAGE

  • Problem Description

    SRM University buys an old scooter for Rs. A and Spends Rs. B on its repairs. if he sells the scooter for Rs.C , what is his gain %? Write C program to compute the gain %?

    Input format:

    The first input is an integer which corresponds to A . The second input is an integer which corresponds to B. The third input is a float which corresponds to gain $
  • CODING ARENA
  • #include <stdio.h>
    int main()
    {
      int a,b,c;
      scanf("%d%d%d",&a,&b,&c);
      printf("The gain percentage is=%0.2f",((c-a-b)*1.0/(a+b))*100);
      return 0;
    }
  • Test Case 1

    Input (stdin)
    4700
    
    800
    
    5800
    
    
    Expected Output
    The gain percentage is=5.45
  • Test Case 2

    Input (stdin)
    5000
    
    700
    
    5800
    
    
    Expected Output
    The gain percentage is=1.75

No comments:

Post a Comment