what do you mean by where did I update my i value ?
UPDATE: I already fixed the infinity loop problem. Only left with both of the printf statements problem.
#include <stdio.h>
#include <string.h>
void info();
void deposit();
void balance();
void withdrawal();
void quit();
//structure declared
struct bank_acc {
int accID; //shortform of "account ID"
char name[20];
float balance;
char password[10];
};
//structure assigned
struct bank_acc account_1 = {11111, "Susan Lee", 10000.0, "passwd1"};
struct bank_acc account_2 = {22222, "James Mason", 20000.0, "passwd2"};
struct bank_acc account_3 = {33333, "Jane Han", 30000.0, "passwd3"};
struct bank_acc account_4 = {44444, "Brian Jacobs", 250000.0, "passwd4"};
struct bank_acc account_5 = {55555, "Clara Wyoming",2500.0, "passwd5"};
int main (void)
{
int i;
printf("Welcome to Ewha Bank\n\n");
printf("1\tDeposit\n");
printf("2\tBalance\n");
printf("3\tWithdrawal\n");
printf("4\tQuit\n\n");
printf("Choose an action\n");
scanf("%d", &i);
printf("\n");
switch(i)
{
case 1 : deposit();
break;
case 2 : balance();
break;
case 3 : withdrawal();
break;
case 4 : quit ();
break;
}
return 0;
}
void deposit()
{
int i = 1;
int accID; //shortform of "account ID"
char password[10];
float deposit, newbalance;
printf("Please enter the amount you would like to deposit: \n");
scanf("%f", &deposit);
printf("\n");
while (i < 4)
{
printf("Please enter your account ID and password\n");
scanf("%d %s", &accID, password);
if (accID==account_1.accID && strcmp(account_1.password, "passwd1"))
{
newbalance = deposit + account_1.balance;
printf("Your current balance is %.2f", newbalance);
}
else if (accID==account_2.accID && strcmp(account_2.password, "passwd2"))
{
newbalance = deposit + account_2.balance;
printf("Your current balance is %.2f", newbalance);
}
else if (accID==account_3.accID && strcmp(account_3.password, "passwd3"))
{
newbalance = deposit + account_3.balance;
printf("Your current balance is %.2f", newbalance);
}
else if (accID==account_4.accID && strcmp(account_4.password, "passwd4"))
{
newbalance = deposit + account_4.balance;
printf("Your current balance is %.2f", newbalance);
}
else if (accID==account_5.accID && strcmp(account_5.password, "passwd5"))
{
newbalance = deposit + account_5.balance;
printf("Your current balance is %.2f", newbalance);
}
else
{
i++;
}
}
}
void balance()
{
//not yet
}
void withdrawal()
{
//not yet
}
void quit()
{
//not yet
}