ATM Sample Project In Simple C Language (

For Beginer

#include<iostream>
#include<conio.h>
#include<stdio.h>
using namespace std;
int location=999,n=0,found=0;

struct user
{

int id;
int pin;
char name[20];
int balance;
};

user atmuser[10];
newuser()
{

int temp;

if(n>9)
printf("Sorry Limit is over \n");
else
{

printf("Enter The The customer Name \n");
scanf("%s",&atmuser[n].name);
printf("Enter The Pin Code \n");
scanf("%d",&atmuser[n].pin);

temp=n+1+100;
printf("%d \n \n ",temp);
atmuser[n].id=temp;
atmuser[n].balance=0;
printf("\n =========================== \n");
printf("\n Welcome Mr. %s \n",atmuser[n].name);
printf("\n Your ID is : %d \n",atmuser[n].id);
printf("\n ===========================\n");
n=n+1;
printf("\nPress Any key To Continue..... \n");
getch();
}
}

search()
{
int id,i;
printf("Enter Your ID \n");
scanf("%d",&id);
for(i=0; i<=10; i++)
{
/*
* If element is found in array then raise found flag
* and terminate from loop.
*/
if(atmuser[i].id == id)
{
found = 1;
location=i;
break;
}

}
}

display()
{
int key;
search();
if(found==1)
{
printf("\n Welcome Mr. %s \n",atmuser[location].name);
printf("enter you pin code \n");
scanf("%d",&key);
if(key==atmuser[location].pin)
{
printf("\n =========================== \n");
printf("\n Mr. %s \n",atmuser[location].name);
printf("\n Your ID is : %d \n",atmuser[location].id);
printf("Your balance is=%d \n",atmuser[location].balance);
printf("\n ===========================\n");
}
else
printf("\n invalid Pin code \n");
}
else
printf("Invalid User ID \n");
printf("\nPress Any key To Continue..... \n");
getch();
}

deposit()
{

int key,tempbalance,amount;
search();
if(found==1)
{
printf("\n Welcome Mr. %s \n",atmuser[location].name);
printf("enter you pin code \n");
scanf("%d",&key);
if(key==atmuser[location].pin)
{
printf("Enter the amount you want to deposit:\n");
scanf("%d",&amount);
tempbalance=atmuser[location].balance+amount;
atmuser[location].balance=tempbalance;

printf("\n =========================== \n");
printf("\n Mr. %s \n",atmuser[location].name);
printf("\n Your ID is : %d \n",atmuser[location].id);
printf("Your balance is=%d \n",atmuser[location].balance);
printf("\n ===========================\n");
}
else
printf("\n invalid Pin code \n");
}
else
printf("Invalid User ID \n");
printf("\nPress Any key To Continue..... \n");
getch();
}

withdraw()
{

int key,tempbalance,amount;

if(found==1)
{
printf("\n Welcome Mr. %s \n",atmuser[location].name);
printf("enter you pin code \n");
scanf("%d",&key);
if(key==atmuser[location].pin)
{
printf("Enter the amount you want to withdraw :\n");
scanf("%d",&amount);
tempbalance=atmuser[location].balance - amount;
atmuser[location].balance=tempbalance;

printf("\n =========================== \n");
printf("\n Mr. %s \n",atmuser[location].name);
printf("\n Your ID is : %d \n",atmuser[location].id);
printf("Your balance is=%d \n",atmuser[location].balance);
printf("\n ===========================\n");
}
else
printf("\n invalid Pin code \n");
}
else
printf("Invalid User ID \n");
printf("\nPress Any key To Continue..... \n");
getch();
}

displaymenu()
{

system("cls") ;
printf("Welcome to our ATM \n");
printf("1.Create New Account \n");
printf("2.Balance Inquriy \n ");
printf("3. Deposit \n");
printf("4.Withdraw \n");
printf("5. Quit \n");

}

int main()
{
int choice=0;

system("cls") ;
do{
displaymenu();
printf("Enter the your Choice: \n");
scanf("%d",&choice);


switch(choice)
{
case 1:
newuser();
break;
case 2:
display();
break;
case 3:
deposit();
break;
case 4:
withdraw();
break;
case 5:
printf("Thnaks For Using ATM Project \n");
printf("Quit");
exit (0) ;
default :
printf("Enter valid choice \n");
}
}while(1);

return 0;
}