when i choice the option deposit then chequing i enter the amoint of 500 but i get a garbage value of total. but when i enter for saving it works. can someone help me
Code:
#include<stdio.h>
#include<conio.h>
#include <stdlib.h>
//void saving();
int chooseAccountType(void);
//int checkingtotal(int a);
main()
{ int num;
int a=0,b=0;
char ct;
int ta;
int aaa,aa,bb;
int total,total1;
int to;
do
{
char a;
printf("\n\n\n\t\tThe Main Menu\n");
printf(" a) Deposit\n");
printf(" b) Withdraw\n");
printf(" c) Add Interest\n");
printf(" d) Account Balance\n");
printf(" e) Exit\n");
printf("Please select one of the choices above (a -> e):");
scanf(" %c",&ct);
if(ct=='a'||ct=='A')
{
aaa= chooseAccountType();
printf("the number is%i",aaa);
if(aaa==1)
{
printf("\nAmmount to be deposit in chequiking=>");
scanf(" %i",&aa);
num=num+aa;
printf("total %i aa %i",num,aa);
}
else if(aaa==2)
{
printf("\nAmmount to be deposit in saving=>");
scanf(" %i",&bb);
total1=total1+bb;
printf("total1 %i bb %i",total1,bb);
}
}
else if(ct=='b'||ct=='B')
{
}
else if(ct=='c'||ct=='C')
{
}
else if(ct=='d'||ct=='D')
{
aaa= chooseAccountType();
printf("number two %i", aaa);
if(aaa==1)
{
printf("Account Balance for checking=>%i",total);
}
else if(aaa==2)
{
printf("Account Balance for saving=>%i",total1);
}
}
else
{
printf("invalid Selection");
}
}
while(ct!='e');
getch();
}
int chooseAccountType(void)
{
int aa,b;
printf("\n1)Chequing");
printf("\n2)Saving");
printf("\nWhich Account would you like to use=>");
scanf(" %i",&aa);
if(aa==1)
{
return(aa);
}
else if(aa==2)
{
return(aa);
}
}