ATM : C++ result showing wrong result

I have written following code for ATM problem. I dont understand why codechef is showing result as wrong answer?

 #include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int x;
float y = 120.00;
cin>>x;
float t = (float)x+0.50;
if(t<=y && x%5==0 && x>0)
{
y=y-t;
cout<<fixed << setprecision(2) <<  y << endl;
}
else
cout<<fixed << setprecision(2) << y<< endl;
return 0;
}

the value of y is not 120 in all cases. you will have to input it also.

Do cin >> x;
and then cin >> y;

1 Like

@aman26:

You cannot assume y=120, you have to input the value of y (similar to x).

#include<stdio.h>
int main()
{
int t;
float b;
scanf("%d",&t);
scanf("%f",&b);
if(t<b && t%5==0)
{
b=b-t-0.5;

}

 
printf("%.2f",b);
return 0;

}