I am new to C++ and am stuck on a program. I've got to create a password check program that makes sure the password rules are followed. Below is the code and the rules i have typed in the comments at the beginning of the program. I have to use loops and cant use arrays for this. Thanks in advance.
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main()
{
//Prompt user to entered a password to be tested
cout << "Password must be at least 8 characters long." << endl;
cout << "Must contain letters and numbers only." << endl;
cout << "And contain a least two numbers." << endl;
cout << "Enter a password: ";
string password;
getline(cin, password);
int low = 0;
//Index of last character entered
int high = password.length() - 1;
int length = password.length();
int digitCount = 0;
bool isValid = false;
while (length >= 8)
{
while (low <= high)
{
if (isalpha(low))
{
isValid = true;
}
else if (isdigit(low))
{
isValid = true;
digitCount++;
}
else
{
isValid = false;
}