You are on page 1of 2

S2 BTech

C Programming
Code-Chef Submission

Name: ANANDHA KRISHNAN. R


Roll No: AM.EN.U4ECE17109

QUESTION: 1: ATM
EASY
Pooja would like to withdraw X
USfromanATM.ThecashmachinewillonlyacceptthetransactionifXisam
ultipleof5,andPooja
′saccountbalancehasenoughcashtoperformthewithdrawaltransaction
(includingbankcharges).Foreachsuccessfulwithdrawalthebankcharges
0.50 US. Calculate Pooja's account balance after an attempted
transaction.
//ANANDHA KRISHNAN.R
#include<stdio.h>
int main()
{
float amt,bal;
scanf("%f %f",&amt,&bal);
if((amt+0.5)<=bal)

printf("%.2f\n",bal-(amt+0.5));
else
printf("%.2f\n",bal);
return 0;
}
APPROACH:
I am taking amt and bal as the input from the user and then I am
finding the amount withdrawned according to the given condition.
From the given data ,balance amount is calculated .If the balance is
greater than the withdrawal ,then subtract 0.5 for each transaction
and print the value.

You might also like