https://ide.codingblocks.com/s/35028
when p is not integer it doesnt show the right answer. it should neglect fractional part instead it neglects integer part. why is that?
Simple interest problem
When you input a float just after int,
And give a floating number in input, the compiler reads only integral part and leaves the rest.
The left out floating part is thus inserted into the the float
For example in code like
{
int p;
float q;
cin>>p>>q;
cout<<p<<" "<<q;
}
When we give input such as
1.025 100
The compiler only reads 1 in p
then .025 is read into q
And 100 is not read at all
Similar happens with your code
got it. thank u so much!
Welcome!!
This was a great doubt and you learn these things only from experimenting and practice.