Code:
int main()
{
int A = 0;//Your variable needs to be initialized, always. If you don't set it to 0, it will be whatever value is stored in the memory A is currently using (unless your compiler auto-initializes.)
int password = 1234;//You need to define your password!
int garbage;//garbage scanned in at the end of the program so it doesn't close automatically
int x;//This should be as far up as possible so as not to interfere with your later code.
printf("Welcome to SeaBank electronic bank service. Seabank, Syncing people with finance.\n At any time you would like to go back through the menu, please press 6\n");
printf("Please enter your four digit password.\n");
//this isn't necessary: scanf("%d",&A);
if (A != password)
{
for (x = 0;(A != password);x++)
{
//This isn't necessary: getchar();
scanf("%d",&A);
if(A == password)break;//You need this line to break out of the loop if the user enters the right value.
printf("Your password is incorrect. Please try again.\n");
if (x == 3) //As AndiPersti has correctly noted, == is a conditional whereas = is an assignment.
{
printf("You have typed in the wrong password too many times. Please consult your bank for further inquiry");
break;
}
}
}
else {}//account(); has not been written yet or is not included in your sample code
scanf("%d",&garbage);//line to scan in a value so the program doesn't close at the end automatically. My compiler closes so I need this to keep it open
return;
}