BCAL - Editorial

Author : codechef_ciem | CodeChef CIEM Chapter

Problem link : Balance Calculator | CodeChef

Problem statement :
Chef would like to withdraw Rs. X from an ATM. The cash machine will only accept the transaction if X is a multiple of 5, and Chef’s account balance has enough cash to perform the withdrawal transaction (including bank charges). For each successful withdrawal the bank charges Rs. 0.50. Calculate Chef’s account balance after an attempted transaction.

Solution :

#include <stdio.h>

int main(void) {
int x;
float y;
float z =0.50; 
scanf("%d %f", &x, &y);
if (x%5==0 && x<=y-z)
	printf("%.2f\n", y-x-z );
} else {
	printf("%.2f\n", y);
return 0;