password: exit after 3 wrong code

How can i make a program that goes like this????

>>program will ask the user to input the password... after 3 wrong password, the program will be terminated...

can you help me? but please make it simple... im a newbie.. thanks!!! ^-^
Nice and simply use a counter. Every time the password is entered make a variable++ until the variable is equal to 3. Then have an "if" statement before the password entry that checks if the variable is equal to or greater than 3.

So for example -
1
2
3
4
5
6
7
8
9
10
loop{
int counter;
if(counter is >= 3)
    exit loop
enter password
if(password is correct)
    do this
else
    counter++
}

Last edited on
closed account (z05DSL3A)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
continue = false
remainingPasswordAtemps = 3

do
{
    Display instruction
    Get username and password
    If username and password are valid
    {
         continue = true
    }
    Else
    {
          --remainingPasswordAtemps
          If remainingPasswordAtemps is zero
               Exit
     } 
}while not continue
...
pseudo code
Last edited on
ahm... excuse me grey wolf... but... can you please tell me where i have to putt this code? sorry....^-^
closed account (z05DSL3A)
It is pseudo code to give you the idea of the logic behind what you will have to do, but the code that you put in would go at the start of your main.
Topic archived. No new replies allowed.