how is my ans wrong ?

//atm

#include<iostream>
using namespace std;
int main()
{
	float bal=120.00;
	int i,j;
	float rec;
	cout<<"\n Your current balance is 120 Rupees only ! \n Enter your withdrawal Amount ";
	cin>>i;
	if(i>bal)
	{
		
	
	{
		cout<<"\n Insufficient Balance ! ";
		rec=bal;
	}
	}
	else
	{
		

	if(i%5==0)
	{
		cout<<"\n Transaction successful !!";
		rec=bal-i-0.50;
	}
	else if(i%5!=0)
	{
		rec=bal;
	}
	}
	cout<<"\n Your balance after transaction is : "<<rec;
	return 0;
}

You don’t have to print statements like

“Enter your withdrawal Amount” “Transaction successful !!” “Your balance after transaction is :” etc

You just have to follow the input/output format of the presented test cases .

This is your corrected code…the errors are pointed out in the code below…

//atm
 
#include<iostream>
using namespace std;
int main()
{
    float bal;      //you need to take bal as input also...it is not 120 by default..!!!
    int i,j;
    float rec;
    /*cout<<"\n Your current balance is 120 Rupees only ! \n Enter your withdrawal Amount ";      no need for such statements*/
    cin>>i>>bal;   //add input for balance
    if(i+0.5>bal)   //see if u can understand what error was here!!!
    {
 
 
    {
        //cout<<"\n Insufficient Balance ! ";  //again no need
        rec=bal;
    }
    }
    else
    {
 
 
    if(i%5==0)
    {
        //cout<<"\n Transaction successful !!";   //again no need
        rec=bal-i-0.50;
    }
    else if(i%5!=0)
    {
        rec=bal;
    }
    }
    cout<<rec<<endl;  //just print the result!!!
    return 0;
}  

NOTE: Strictly follow the i/o format…as mentioned in the ques…no need to give out such statements unless ne such thing is mentioned in the problem statement…hope this helps…:slight_smile:

//