Canna

Thursday, 27 September 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 %
  • 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
  • Program
  • #include <stdio.h>
    int main()
    {
       int a,b,c;
      scanf("%d%d%d",&a,&b,&c);
      printf("The gain percentage is=%.2f",((c-a-b)*1.0/(a+b))*100);
     return 0;
    }

No comments:

Post a Comment

Note: only a member of this blog may post a comment.