Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

c++ program for inflation rate of two numbers

#include <iostream>
using namespace std;
double InflationRate(float x, float z);
int main()
{  
    float x, z;
    cout << "Enter the old indicies:";
    cin >> x;
    cout << "Enter the new indicies:";
    cin>> z;
    double Rate = InflationRate(x, z);
    cout << "Inflation rate is: " << Rate << endl;
    return 0;
}
double InflationRate (float x, float z)
{
   if(x<0||z<0||x==0)
   return 0;
   return (z - x) / x * 100;

}
 
PREVIOUS NEXT
Tagged: #program #inflation #rate #numbers
ADD COMMENT
Topic
Name
2+4 =