hello
im writing a program that will give the rate of inflation for the past year. it asks for the price of an item for this time and the price of the same item a year ago. i want to give the inflation rate as a percent with the type double. i dont understand what is going wrong with it, it will skip the second input if i use decimals, and the inflation comes out weird. please give me some hints about it.
Code:
#include<iostream>
using namespace std;
double inflationrate(int now, int yearago);
int main()
{
int now, yearago;
double inflation;
cout<<"Enter the price of something today: $";
cin>>now;
cout<<"Enter the price of the same thing one year ago: $";
cin>>yearago;
cout<<"You have an inflation of "<<inflationrate<<"%\n";
system("pause");
return 0;
}
double inflationrate(int now, int yearago)
{
return (((now-yearago)/yearago)); // inflation rate is what is inside the parentheses
}