#include<stdio.h>
#include<conio.h>
main()
{
int num, dep, with, bal;
clrscr();
num=1;

printf("MENU");
printf("\n\n1. Deposit\n2. Withdraw\n3. Check Balance");

printf("\n\nEnter a number of choice: ");
scanf("%d", &num);

switch(num)
{
case 1: printf("\n\n\nEnter an amount to be deposited: ");
scanf("%d", &dep);
{
printf("You have successfully deposited an amount of %d.", dep);
}
getch();
case 2: printf("\n\nEnter an amount to be withdrawn: ");
scanf("%d", &with);
{
num=dep-with;
printf("\n\nYou have succesfully withrawn %d", with);
}
getch();

case 3: printf("\n\nYour current balance is %d.", num);
}
getch();
}

and

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

main()
{
    int choice;
    float balance = 0.0;
    do{
        float amount = 0.0;
        do{
            clrscr();
            printf("MENU\n1. Deposit\n2. Withdraw\n3. Balance Inquiry\n");
            printf("4. Fast Cash\n5. Exit\nEnter choice: ");
            scanf("%d",&choice);
            if (choice < 1 || choice > 5)
            {
                printf("Error in choice.\nPress any key to continue.");
                getch();
            }
        }while(choice < 1 || choice > 5);
        switch(choice)
        {
            case 1: printf("Enter amount to deposit: ");
                            scanf("%f",&amount);
                            if (amount < 0.01)
                            {
                                printf("Error in input of amount. ");
                                printf("Press any key to continue.");
                                getch();
                            }
                            else
                            {
                                balance += amount;
                                printf("You deposited %.2f.\n");
                                printf("Your current balance is %.2f",amount,balance);
                                printf("\nPress any key to continue.");
                                getch();
                            }
                            break;
            case 2: if (balance > 0.0)
                            {
                                printf("Enter amount to withdraw: ");
                                scanf("%f",&amount);
                                if(amount < 0.01 || amount > balance)
                                {
                                    printf("Error in input of amount. ");
                                    printf("Press any key to continue.");
                                    getch();
                                }
                                else
                                {
                                    balance -= amount;
                                    printf("You withdrew %.2f.\n",amount);
                                    printf("Your current balance is %.2f",balance);
                                    printf("\nPress any key to continue.");
                                    getch();
                                }
                            }
                            else
                            {
                                printf("Insufficient funds.\nPress any key to continue.");
                                getch();
                            }
                            break;
            case 3: printf("Your balance is %.2f.\n",balance);
                            printf("Press any key to continue.");
                            getch();
                            break;
            case 4: if(balance >= 100.0)
                            {
                                int c;
                                printf("FASTCASH MENU\n1. 100\n2. 200\n3. 500\n4. 1000\n");
                                printf("Enter choice: ");
                                scanf("%d",&c);
                                switch(c)
                                {
                                    case 1: amount = 100.0;
                                                    break;
                                    case 2: amount = 200.0;
                                                    break;
                                    case 3: amount = 500.0;
                                                    break;
                                    case 4: amount = 1000.0;
                                                    break;
                                    default: printf("Choice does not exist. ");
                                                     printf("Press any key to continue.");
                                                     getch();
                                                     amount = 0.0;
                                }
                                if(balance >= amount)
                                {
                                    balance -= amount;
                                    printf("You withdrew %.2f.",amount);
                                    printf("Your current balance is %.2f",balance);
                                    printf("\nPress any key to continue.");
                                    getch();
                                }
                                else
                                {
                                    printf("Insufficient funds.\nPress any key to continue.");
                                    getch();
                                }
                            }
                            else
                            {
                                printf("Insufficient funds.\nPress any key to continue.");
                                getch();
                            }
        }
    }while(choice != 5);
}

here are some atm program I just made... the problem is I don't know how function works... Need guidance guys! Gotta finish it ASAP... XD

I need some guidance in adding some freaking function with my ATM program... Pls help me out guys!

ok let me help, but the ATM program is not that difficult, but take a look at this sample codes...

/* An ATM machine program collection, designed by Justicce Igwe */
#include<stdio.h>
char choose,option;
#include<conio.h>
#include<string.h>
#include<stdlib.h>
	int main()
	{
	char choice;
	int i;
	char choice_file;
	float amount=0,transfer=0,withdraw=0,deposit=0;
	float amount1=0,transfer1=0,withdraw1=0,deposit1=0;
	char password[50],password1[50];

	FILE *atmfile;
	clrscr();
	loop1:
	clrscr();
	     printf("\n\t\t Enter Password\n\t\tPassword : [                           ] ");
	  gotoxy(29,3);   scanf("%s",password);

	     clrscr();
	     printf("\n\t\t Confirm Password\n\t\tPassword : [                           ] ");
	  gotoxy(29,3);  scanf("%s",password1);

	     if(strlen(password1)!=strlen(password))
	     {
	     clrscr();
	   gotoxy(1,7);  printf("\t\t\t\t Access denied ");
	     getch();
	     goto loop;
	     }
	     else if(strlen(password1)==strlen(password))
	     {
	     clrscr();
	   gotoxy(1,7);  printf("\t\t\t\t Access Granted ");
	     getch();
	     goto label;
	     }

	label:
	clrscr();
			for(i=1;i<=79;i++)
			printf("&");
			printf("\t\t\t Justice Igwe's ATM Collection \n");
			for(i=1;i<=79;i++)
			printf("&");

	  printf("\t\t\t\t ATM COLLECTION MENU\n");
	  printf("\n\t\t\t[i] : Inquire Balance ");
	  printf("\n\t\t\t[w] : Withdrawal      ");
	  printf("\n\t\t\t[d] : Deposit Cash	");
	  printf("\n\t\t\t[t] : Transfer Cash   ");
	  printf("\n\t\t\t    : Choose  [ ]     ");
	       gotoxy(40,10);	scanf("\n%c",&choice);
			switch(choice)
			{
			case 'i':clrscr();
				printf("\n\t\t\t Choose Account Type  ");
				printf("\n\t\t[c]: Current Account   \t\t[s]: Savings Account ");
				printf("\n\t\t\t\t Choose Account [ ]	");
			     gotoxy(50,4);	scanf("\n%c",&option);
								switch(option)
								{
								case 'c':clrscr();
								printf("\n\t\t Current Account  ");
									if(amount==NULL||amount<0)
									{
									clrscr();
									 printf("\n\t\t You Have No Money In Your Account ");
									 getch();
									      gotoxy(1,6);	printf("\n\t Perform Another Transaction (y/n) : [ ] ");
											      gotoxy(47,7);	scanf("\n%c",&choose);
													if(choose=='n'||choose=='N')
													{
													clrscr();
													    gotoxy(1,6);	printf("\n\t\t\t Thank You For Banking ");
														getch();
														exit(0);
														}
															else if(choose=='y'||choose=='Y')
															{
															goto label;
															}

									 } else if(amount!=NULL||amount>0)
											{
											clrscr();
											printf("\n Your Current Account Balance is $%.4f left",amount);

											}
											getch();
								break;
								case 's':clrscr();
								printf("\n\t\t Savings Account ");

									if(amount1==NULL||amount1<0)
									{
									clrscr();
									 printf("\n\t\t You Have No Money In Your Account ");
									 getch();
									      gotoxy(1,6);	printf("\n\t Perform Another Transaction (y/n) : [ ] ");
											      gotoxy(47,7);	scanf("\n%c",&choose);
													if(choose=='n'||choose=='N')
													{
													clrscr();
													    gotoxy(1,6);	printf("\n\t\t\t Thank You For Banking ");
														getch();
														exit(0);
														}
															else if(choose=='y'||choose=='Y')
															{
															goto label;
															}

									 } else if(amount1!=NULL||amount1>0)
											{
											clrscr();
											printf("\n Your Savings Account Balance is $%.4f left",amount1);

											}
											getch();



								break;
								default:
								printf("\n\t\t\t Exiting ");
								}





					clrscr();
					printf("\n\t\t Re - Choose Operation  (y/n) :  [ ]  ");
		     gotoxy(51,2);	scanf("\n%c",&choice);

				if(choice=='n'||choice=='N')
					{
					clrscr();
						printf("\n\t\t Operation Terminated.. ......... Thank You.. ");
						getch();
						 exit(0);
						 }
						 else if(choice=='y'||choice=='Y')
							{
							goto label;
							}
		   
				break;
				case 'w':clrscr();
				printf("\n\t\t\t Choose Account Type ");
				printf("\n\t\t[c]: Current Account   \t\t[s]: Savings Account  ");
				printf("\n\t\t\t\t Choose Account [ ] 	");
			      gotoxy(50,4);	scanf("\n%c",&choose);
						switch(choose)
						{
							case 'c':clrscr();
							printf("\n\t\t\t Enter Amount To Withdraw ");
							printf("\n\t\t\t\t [                   ]    ");
							gotoxy(35,3); scanf("%f",&withdraw);

									if((withdraw==NULL)||(withdraw<0)||(amount==NULL)||(amount<0)||(withdraw>amount))
									{
									clrscr();
									 printf("\n\t\t You Have No Money In Your Account To Withdraw ");

									 getch();
									      gotoxy(1,6);	printf("\n\t Perform Another Transaction (y/n) : [ ] ");
											      gotoxy(47,7);	scanf("\n%c",&choose);
													if(choose=='n'||choose=='N')
													{
													clrscr();
													    gotoxy(1,6);	printf("\n\t\t\t Thank You For Banking ");
														getch();
														exit(0);
														}
															else if(choose=='y'||choose=='Y')
															{
															goto label;
															}


									 } else if((withdraw!=NULL)||(withdraw>0)||(amount!=NULL)||(amount>0)||(withdraw<amount))
											{
											clrscr();
											amount-=withdraw;
											printf("\n You've Withdrawn  $%.4f From Your Current Account",withdraw);
											 getch();
											}
											break;
									   case 's':clrscr();
											      printf("\n\t\t\t Enter Amount To Withdraw ");
											      printf("\n\t\t\t\t [                    ]   ");
											      gotoxy(35,3); scanf("%f",&withdraw1);
									if((withdraw1==NULL)||(withdraw1<0)||(withdraw1>amount1)||(amount1==NULL)||(amount1<0))
									{
									clrscr();
									 printf("\n\t\t You Have No Money In Your Account ");
									 getch();
									      gotoxy(1,6);	printf("\n\t Perform Another Transaction (y/n) : [ ] ");
											      gotoxy(47,7);	scanf("\n%c",&choose);
													if(choose=='n'||choose=='N')
													{
													clrscr();
													    gotoxy(1,6);	printf("\n\t\t\t Thank You For Banking ");
														getch();
														exit(0);
														}
															else if(choose=='y'||choose=='Y')
															{
															goto label;
															}

									 } else if((withdraw1!=NULL)||(withdraw1>0)||(amount1!=NULL)||(amount>0)||(withdraw<0))
											{
											clrscr();
											amount1-=withdraw1;
											printf("\n You've Withdrawn  $%.4f From Your Savings Account",withdraw1);
												 getch();
											}

										      //	getch();

												    break;
												 }  clrscr();
					printf("\n\t\t Re - Choose Operation  (y/n) :  [ ]  ");
		     gotoxy(51,2);	scanf("\n%c",&choice);
				if(choice=='n'||choice=='N')
					{
					clrscr();
						printf("\n\t\t Operation Terminated.. ......... Thank You.. ");
						getch();
						 exit(0);
						 }
						 else if(choice=='y'||choice=='Y')
							{
							goto label;
							}

					break;
					case 'd':clrscr();
								printf("\n\t\t\t Choose Account Type ");
				printf("\n\t\t[c]: Current Account   \t\t[s]: Savings Account  ");
				printf("\n\t\t\t\t Choose Account [ ] 	");
			      gotoxy(50,4);	scanf("\n%c",&choose);
						switch(choose)
						{
							case 'c':clrscr();
						       printf("\n\t\t\t Enter Amount To Deposit   ");
						       printf("\n\t\t\t\t [                    ]    ");
						      gotoxy(35,3); scanf("%f",&deposit);
									if((deposit==NULL)||(deposit<0))
									{
									clrscr();
									 printf("\n\t\t You Have No Money In Your Account To Deposit ");
									 getch();
									      gotoxy(1,6);	printf("\n\t Perform Another Transaction (y/n) : [ ] ");
											      gotoxy(47,7);	scanf("\n%c",&choose);
													if(choose=='n'||choose=='N')
													{
													clrscr();
													    gotoxy(1,6);	printf("\n\t\t\t Thank You For Banking ");
														getch();
														exit(0);
														}
															else if(choose=='y'||choose=='Y')
															{
															goto label;
															}

									 } else if((deposit!=NULL)||(deposit>0))
											{
											clrscr();
											amount+=deposit;
											printf("\n You've Deposited  $%.4f In Your Current Account",amount);

											}
											break;
									   case 's':clrscr();
									     printf("\n\t\t Enter Amount To Deposit ");
									     printf("\n\t\t\t [                    ]    ");
									   gotoxy(27,3);  scanf("%f",&deposit1);
									if((deposit1==NULL)||(deposit1<0))
									{
									clrscr();
									 printf("\n\t\t You Have No Money In Your Account ");
									 getch();
									      gotoxy(1,6);	printf("\n\t Perform Another Transaction (y/n) : [ ] ");
											      gotoxy(47,7);	scanf("\n%c",&choose);
													if(choose=='n'||choose=='N')
													{
													clrscr();
													    gotoxy(1,6);	printf("\n\t\t\t Thank You For Banking ");
														getch();
														exit(0);
														}
															else if(choose=='y'||choose=='Y')
															{
															goto label;
															}

									 } else if((deposit1!=NULL)||(deposit1>0))
											{
											clrscr();
											amount1+=deposit1;
										      //	printf("\n You've Deposited  $%.4f In Your Savings Account ",amount1);

											}

										     //	getch();

												break;
												 }  clrscr();

						printf("\n\t\t Re - Choose Operation  (y/n) :  [ ]  ");
		     gotoxy(51,2);	scanf("\n%c",&choice);
				if(choice=='n'||choice=='N')
					{
					clrscr();
						printf("\n\t\t Operation Terminated........... Thank You.. ");
						getch();
						 exit(0);
						 }
						 else if(choice=='y'||choice=='Y')
							{
							goto label;
							}

						break;
						case 't':clrscr();
									printf("\n\t\t\t Choose Account Type ");
				printf("\n\t\t[c]: Current Account   \t\t[s]: Savings Account  ");
				printf("\n\t\t\t\t Choose Account [ ] 	");
			      gotoxy(50,4);	scanf("\n%c",&choose);
						switch(choose)
						{
							case 'c':clrscr();
						       printf("\n\t\t\t Enter Amount To Tansfer   ");
						       printf("\n\t\t\t\t [                 ]    ");
						      gotoxy(35,3); scanf("%f",&transfer);
									if((transfer==NULL)||(transfer<0)||(amount==NULL)||(amount<0))
									{
									clrscr();
									 printf("\n\t\t You Have No Money In Your Account To Transfer ");
									 getch();
									      gotoxy(1,6);	printf("\n\t Perform Another Transaction (y/n) : [ ] ");
											      gotoxy(47,7);	scanf("\n%c",&choose);
													if(choose=='n'||choose=='N')
													{
													clrscr();
													    gotoxy(1,6);	printf("\n\t\t\t Thank You For Banking ");
														getch();
														exit(0);
														}
															else if(choose=='y'||choose=='Y')
															{
															goto label;
															}

									 } else if((transfer!=NULL)||(transfer>0)||(amount!=0)||(amount>0))
											{
											clrscr();
											amount-=transfer;
										      //	printf("\n Your Current Account Balance is $%.4f left",amount);

											}
											break;
									   case 's':clrscr();
									     printf("\n\t\t Enter Amount To Transfer ");
									     printf("\n\t\t\t [                 ]    ");
									   gotoxy(27,3);  scanf("%f",&transfer1);
									if((transfer1==NULL)||(transfer1<0)||(amount1==NULL)||(amount1<0))
									{
									clrscr();
									 printf("\n\t\t You Have No Money In Your Account To Transfer ");
									 getch();
									      gotoxy(1,6);	printf("\n\t Perform Another Transaction (y/n) : [ ] ");
											      gotoxy(47,7);	scanf("\n%c",&choose);
													if(choose=='n'||choose=='N')
													{
													clrscr();
													    gotoxy(1,6);	printf("\n\t\t\t Thank You For Banking ");
														getch();
														exit(0);
														}
															else if(choose=='y'||choose=='Y')
															{
															goto label;
															}

									 } else if((transfer1!=NULL)||(transfer1>0)||(amount1!=NULL)||(amount1>0))
											{
											clrscr();
											amount1-=transfer1;
										      //	printf("\n Your Savings Account Balance is $%.4f left",amount1);

											}

											getch();

												break;
												 }  clrscr();

							printf("\n\t\t Re - Choose Operation  (y/n) :  [ ]  ");
		     gotoxy(51,2);	scanf("\n%c",&choice);
				if(choice=='n'||choice=='N')
					{
					clrscr();
						printf("\n\t\t Operation Terminated.. ......... Thank You.. ");
						getch();
						 exit(0);
						 }
						 else if(choice=='y'||choice=='Y')
							{
							goto label;
							}

							break;

						default:  clrscr();
						loop:
						clrscr();
							      gotoxy(1,8);	printf("\n\t\t\t Try Again (y/n): [ ] ");
										gotoxy(44,9);   scanf("\n%c",&choice);
												if(choice=='y'||choice=='Y')
								{
								goto loop1;
								}
								else if(choice=='n'||choice=='N')
								{
								goto exit;
								}

								exit:
								clrscr();
					      gotoxy(1,8);	printf("\n\t\t\t\t Exiting ");
							  getch();
							  exit(0);

	 getch();
	      }
	      return 0;
	      }

hope this will help...

commented: The code is plain stupid at best +0

Use the DENNIS RICHIE c compiler, because the dev c++ do not support most of the functions i have inserted...

How you wrote these functions without knowing what they do is beyond me, however i will rey to expain what the code does. First some formatting please.. and explanation is in the comments

#include<stdio.h>
#include<conio.h>
main()
{
int num, dep, with, bal; 
// [B]dep[/B] - deposited amt, [B]bal[/B] - balance, [B]with[/B]- amount withdraw-ed
clrscr();
num=1;

printf("MENU");
printf("\n\n1. Deposit\n2. Withdraw\n3. Check Balance");

printf("\n\nEnter a number of choice: ");
scanf("%d", &num); //Entering choice of operation here

switch(num) //performing appropriate operation 
{
case 1: printf("\n\n\nEnter an amount to be deposited: ");
scanf("%d", &dep);
{
printf("You have successfully deposited an amount of %d.", dep);
// Actually you must do [B]bal=bal+dep;[/B]. Only then have u actually deposited the amt
// without that you will be [I]scamming[/I] your customers lol.
}
getch();
case 2: printf("\n\nEnter an amount to be withdrawn: ");
scanf("%d", &with);
{
//You must first check that the amount being withdraw-ed is lesser than balance.
// [B]if(with>bal) printf("Not enough funds);[/B]
//[B]else{[/B]
num=dep-with; // [B]bal = bal-with;[/B] Remember num represents the user's choice of operation i.e - withdraw, deposit etc.


printf("\n\nYou have succesfully withrawn %d", with);//[B]}[/B]
}
getch();

case 3: printf("\n\nYour current balance is %d.", num); // again bal hold the balance. 
}
getch();
}

This is it for now i will edit later and further explain

o.O btw why can't i format the code like justice did it in the post above ?

Use the code tag..
After you have pasted your code into the little box, select all the code and then click on the (CODE)
Preview your post to see if the formatting has come out correctly or not

oh, kakashi? R u trying to say that the program i've written isn't good, if ''yes'' then y, if ''no'' tnks . I appreciate ur concern, bt although, thinking of codes aint that easy.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.