ATM CodeChef soultion in C language with logic
first discuss this points because it related to problem
Primarily there are 3
types of constant:
1. Integer constant = -1,8,9
2. Real constant =
-322.9,2.5,7.0
3. Character constant = ‘a’,’$’,’@’(must be enclosed within single inverted commas)
For print we use printf("%d",integer_constant);
//%d for integer constant
//%f for real constant
//%c for character constant
So here the code-->
#include <stdio.h>
int main() {
int X;
float Y;
scanf("%d %f",&X,&Y);
if(X%5!=0){
printf("%.2f",Y);
}
else if(X+0.5>Y){
printf("%.2f",Y);
}
else{
printf("%.2f",Y-(X+0.5));
}
return 0;
}
so the logic is first we declare variable then we get input by user as you see above through scanf. then their is condition that the atm machine would accept only multiple of five so we use conditional statement that if its not multiple of five and the amount is bigger then Y then its show balance before it have because no transaction occur. otherwise its give the result of remaining balance.
Thank You
Comments
Post a Comment
If you have any doubts let me know