C program for atm transactions





1. C code for atm transaction while currencies are 1000,500 
and 100

2. ATM c program source code
3. C program for atm machine
4. C program for atm banking

#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




1. Write a c program to convert decimal number to hexadecimal number.
3. Write a c program to convert octal number to decimal number.
4. Write a c program to convert octal number to hexadecimal number.
5. Write a c program to convert hexadecimal number to decimal number.
6. Write a c program to convert hexadecimal number to octal number.
8. Write a c program to convert binary number to hexadecimal number.
9. Write a c program to convert binary number to octal number.
11. Write a c program to convert hexadecimal number to binary number.
12. Write a c program to convert octal number to binary number.
14. Write a c program to convert centigrade to fahrenheit.

8 comments:

Unknown said...

good web site

Anonymous said...

int totalFiveFundred =1000;
You misspelled Hundred :)

Anil Kumar said...
This comment has been removed by the author.
Anonymous said...

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;
}

Bhat Asif said...

This Code is wrong.
If withdrawAmount = 7800,
thousand = 7.8.

Unknown said...

This code is correct . Thousand is an INTEGER . NOT FLOAT

Unknown said...

plzz make me same code with the following specifications
TEST cases for ATM Machine

1. Machine is accepting ATM card

2. Machine is rejecting expired card

3. Succesful entry of PIN number
4. Unsuccessful operation due to wrong PIN number 3 times

5. Succesful selection of language

6. Successful selection of account type.

7. Unsuccessful operation due to invalid account type

8. Succesful selection of amount to be with draw

9. Succesful withdraw

10. Expected meggage due to amount is greater than day limit

11. Unsuccesful withdraw operation due to lack of money in ATM

12. Expected message due to amount to withdraw is greater than possible balance

13. Unsuccessful withdraw operation due to click after insert card.
and mail me to annusmartguy@gmail.com

Fawn Leathers said...

Hey Dear,
How to possible????
"if thousand = 7.8 greater than totalThousand = 1000..."
IF condition not run, because 7.8 not greater than 1000
Below your condition...

thousand = withdrawAmount / 1000; // return 7.8
"if(thousand > totalThousand)"