Saturday, 28 April 2012

Prototype C Program for an ATM Machine Transaction


#include<stdio.h>
#include<conio.h>

int total1000 =1000;
int total500 =1000;
int total100 =1000;

int main()
{

    unsigned long amount;
    unsigned long totalmoney;

    int thou=0,five=0,hund=0;

    printf("Enter amount in multiples of 100!");
    scanf("%lu",&amount);

    if(amount %100 != 0){
  printf("Please Enter in Multiples of 100!");
  return 0;
    }

    totalmoney = total1000 * 1000 + total500* 500 +  total100*100;

    if(amount > totalmoney){
  printf("Sorry, Paise Nahin Hain!");
  return 0;
    }

    thou = amount / 1000;
    if(thou > total1000)
  thou = total1000;
    amount = amount - thou * 1000;

    if (amount > 0){
  five = amount / 500;
  if(five > total500)
      five = total500;
  amount = amount - five * 500;
    }

    if (amount > 0)
  hund = amount / 100;

    printf("Total 1000 note: %d\n",thou);
    printf("Total  500 note: %d\n",five);
    printf("Total  100 note: %d\n",hund);
    getch();
    return 0;
}

No comments:

Post a Comment