shaadi.com

Searching...
Wednesday, 12 June 2013

Assignment 2


/* Assignment
Program no. EX2.c */

//Automatic Cash register program

void main()
{
unsigned int a,b,c,temp=0,rem=0,pay=0;
clrscr();

printf("\n\n Automatic Cash register Program \n\n");

printf("\n Enter the Customer's purchase price:- Rs. ");
scanf("%d",&a);

printf("\n Enter the amount of money handed over by customer:- Rs. ");
scanf("%d",&b);

if(b<a || b<0 || a<0)
{
printf("\n Error: Either the Customer's purchase price or the amount \n handed over by customer is incorrect \n");
printf("\n Enter the Customer's purchase price:- Rs. ");
scanf("%d",&a);
printf("\n Enter the amount of money handed over by customer:- Rs. ");
scanf("%d",&b);

if(b<a || b<0 || a<0)     //If input is wrong twice
{ printf("\n\n Error: Press any key to exit....");
getch();
exit(1);
}
}

   printf("\n\n Number of notes to be handed over to the customer:- \n");

c=b-a;
pay=c;

if(pay>=1000)
{
rem=0;
temp=0;
rem = pay / 1000;
temp = rem * 1000;
printf("\n Pay %d Note/s of Rs. 1000 = Rs. %d ",rem,temp);
pay = pay - temp;
}
if(pay>=500)
{
rem=0;
temp=0;
rem=pay/500;
temp=rem*500;
printf("\n Pay %d Note/s of Rs. 500 = Rs. %d ",rem,temp);
pay=pay-temp;
}
if(pay>=100)
{
rem=0;
temp=0;
rem=pay/100;
temp=rem*100;
printf("\n Pay %d Note/s of Rs. 100 = Rs. %d",rem,temp);
pay=pay-temp;
}
if(pay>=50)
{
rem=0;
temp=0;
rem=pay/50;
temp=rem*50;
printf(" \n Pay %d Note/s of Rs. 50 = Rs. %d",rem,temp);
pay=pay-temp;
}
if(pay>=20)
{
rem=0;
temp=0;
rem=pay/20;
temp=rem*20;
printf("\n Pay %d Note/s of Rs. 20 = Rs. %d",rem,temp);
pay=pay-temp;
}
if(pay>=10)
{
rem=0;
temp=0;
rem=pay/10;
temp=rem*10;
printf("\n Pay %d Note/s of Rs. 10 = Rs. %d",rem,temp);
pay=pay-temp;
}
if(pay>=5)
{
rem=0;
temp=0;
rem=pay/5;
temp=rem*5;
printf("\n Pay %d Note/s of Rs. 5 = Rs. %d",rem,temp);
pay=pay-temp;
}
if(pay>=2)
{
rem=0;
temp=0;
rem=pay/2;
temp=rem*2;
printf("\n Pay %d Note/s of Rs. 2 = Rs. %d",rem,temp);
pay=pay-temp;
}
if(pay>=1)
{
rem=0;
temp=0;
rem=pay/1;
temp=rem*1;
printf("\n Pay %d Note/s of Re.1 = Rs. %d",rem,temp);
pay=pay-temp;
}


printf("\n\n Payed Rs. %d to the customer\n",c);
printf("\n\n\n Press any key to exit...");
getch();


}

0 comments:

Post a Comment