atm

ATM transaction

Posted on

ATM kan hman chuan a pawisa awmdan a zirin kan pawisa duhzat mil kha a rawn chhuak thin a .Engtin nge khawl khan 100 note lo chhuak zat tur te , 500 note lo chhuak zat turte a hriat mai theih ?? C program hmangin hetiang hi logic awlsam leh ho tak hmangin a tih theih ani . Han en chhin teh le..

#include<stdio.h>
int totalThousand =1000;
int totalFiveFundred =1000;
int totalOneHundred =1000;
int main(){
    unsigned long withdrawAmount;
    unsigned long totalMoney;
    int thousand=0,fiveHundred=0,oneHundred=0;
    printf(“Enter the amount in multiple of 100: “);
    scanf(“%lu”,&withdrawAmount);
    if(withdrawAmount %100 != 0){
         printf(“Invalid amount;”);
         return 0;
    }
    totalMoney = totalThousand * 1000 + totalFiveFundred* 500 +  totalOneHundred*100;
    if(withdrawAmount > totalMoney){
         printf(“Sorry,Insufficient money”);
         return 0;
    }
    thousand = withdrawAmount / 1000;
    if(thousand > totalThousand)
         thousand = totalThousand;
    withdrawAmount = withdrawAmount – thousand * 1000;
    if (withdrawAmount > 0){
         fiveHundred = withdrawAmount / 500;
         if(fiveHundred > totalFiveFundred)
             fiveHundred = totalFiveFundred;
         withdrawAmount = withdrawAmount – fiveHundred * 500;
    }
    if (withdrawAmount > 0)
         oneHundred = withdrawAmount / 100;
    printf(“Total 1000 note: %d\n”,thousand);
    printf(“Total  500 note: %d\n”,fiveHundred);
    printf(“Total  100 note: %d\n”,oneHundred);
    return 0;
}
Sample output:
Enter the amount in multiple of 100: 7800
Total 1000 note: 7
Total  500 note: 1
Total  100 note: 3
KHIMI CODE KHI SEI I TIH DEUH CHUAN ,a hnuaia mi ang khuan a tih tawi deuh theih a,..khu ai tawi khu chuan ka ti thei tawh tlat lo .A code tihdan dang deuh in hriat chuan comments lamah in feedback ka lo chang reng ang .. 🙂
int main()
{
int amt;
printf(“Enter the amount to withdraw : “);
scanf(“%d”,&amt);
printf(“\nNotes of 1000 required are %d”, amt/1000);
printf(“\nWhile Notes of 500 required are %d”, ((amt % 1000)/500));
printf(“\nAnd notes of 100 required are %d”,((amt % 1000)% 500)/100);

getch();
return 0;
}