Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

atm problem need help

$
0
0
#include <stdio.h>
#include <stdlib.h>

#ifndef BANK_CHARGE
#define BANK_CHARGE  0.5
#endif;

int main (int argc, char **argv){
// if(argc != 3){
//   printf("Usage: %s [int] [float]\n", argv[0]);
//   exit(1);
// }

int withdraw = atoi(argv[1]);
float balance = atof(argv[2]);

if((withdraw % 5) != 0){
printf("%.2f", balance);
exit(1);
}
if(withdraw > 2000 || withdraw == 0){
printf("%.2f", balance);
exit(1);
}

float totalWithdraw = (withdraw + BANK_CHARGE);

if(totalWithdraw >= balance){
printf("%.2f", balance);
exit(1);
}

printf("%.2f", balance - totalWithdraw);
return 0;
}

this is my code and its showing runtime error


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>