i need the loop to break when i enter the new password.
right now whenever i enter the new password, it shows " your password has been changed" and it goes back to " Please enter your 4 - digit password ". i want it to end on " your password has been changed ". help
#include <iostream>
usingnamespace std;
void main()
{
int userID = 0;
int password = 0;
int newpassword = 0;
cout << "Please enter your 6-digit user id: ";
cin >> userID;
for ( int c=3; c>0; c--)
if (userID == 286957)
{
cout << "Please enter your 4-digit password: ";
cin >> password;
for ( int c=3; c>0; c--)
if (password == 2468)
{
cout << "Logged in successfully. You should change your password at the first login. \nThe new password should be a 4-digit number and different from \nthe current password. ";
cout << "Please enter your new 4-digit password: ";
cin >> newpassword;
cout << "Your password has been changed \n";
}
else
{
cout << "Invalid userID/password. You can try "<< c << " more time/s \n";
cin >> password;
}
break;
}
else
{
cout << "Invalid userID/password. You can try "<< c << " more time/s \n";
cin >> userID;
}
system ("pause");
}
#include <iostream>
usingnamespace std;
int main()
{
int userID = 0;
int password = 0;
int newpassword = 0;
cout << "Please enter your 6-digit user id: ";
cin >> userID;
for ( int c=3; c>0; c--)
if (userID == 286957)
{
cout << "Please enter your 4-digit password: ";
cin >> password;
for ( int c=3; c>0; c--)
if (password == 2468)
{
cout << "Logged in successfully. You should change your password at the first login. \nThe new password should be a 4-digit number and different from \nthe current password. ";
cout << "Please enter your new 4-digit password: ";
cin >> newpassword;
cout << "Your password has been changed \n";
break;
}
else
{
cout << "Invalid userID/password. You can try "<< c << " more time/s \n";
cin >> password;
}
break;
}
else
{
cout << "Invalid userID/password. You can try "<< c << " more time/s \n";
cin >> userID;
}
system ("pause");
}
i need the loop to break when i enter the new password.
you answered it, put a break when you want it to break.