I am facing issue with result output with long int
. Here Below is my Program, I am calculating tax with various methods 1) taking result output in int
and long
variable. I think all the four results in my code should be the same, but result output in tax3
variable is coming different (less by 1) than other three. please help me to understand the reason.
#include<iostream.h>
#include<conio.h>
int main()
{
long salary;
cout << "Enter Salary: " << endl;
cin>>salary;
float tax1, tax2;
long tax3, tax4;
tax1 = salary*0.15;
tax2 = (salary*15)/100;
tax3 = salary*0.15;
tax4 = (salary*15)/100;
cout << "tax1=" << tax1 << endl;
cout << "tax2=" << tax2 << endl;
cout << "tax3=" << tax3 << endl;
cout << "tax4=" << tax4 << endl;
getch();
return(0);
}