VOOZH about

URL: https://www.geeksforgeeks.org/dsa/program-to-find-the-percentage-of-difference-between-two-numbers/

⇱ Program to find the percentage of difference between two numbers - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Program to find the percentage of difference between two numbers

Last Updated : 7 Jul, 2022

Given two numbers a and b, where 'b' is incremented or decremented by some percentage of 'a'. The task is to find out that percentage.

Examples: 

Input: a = 20, b = 25
Output: 25% 
Difference between 20 and 25 is 5, 
which is 25 % of 20.
(+ve sign indicate increment)

Input: a = 25, b = 20
Output: -20% 
( -ve sign indicate decrement)


Formula to calculate percentage: 

(Percentage2 - Percentage1) * 100 / (Percentage1) 
  


Output: 
25%

 

Time Complexity: O(1)
Auxiliary Space: O(1)

Comment
Article Tags:
Article Tags: