Question
I need help with my computer science course. I do not know why there is no response at all once I input data into char
I need help with my computer science course.
I do not know why there is no response at all once I input data into char passWord array.
Below is my code:
#include
#include
#include
using namespace std;
bool testPassWord(char[]);
int countLetters(char*);
int countDigits(char*);
int main()
{
int numLetters, numDigits;
char passWord[20];
cout
cin.getline(passWord,20);
if(testPassWord(passWord))
cout
else
cout
numLetters = countLetters(passWord);
numDigits = countDigits(passWord);
cout
cout
return 0;
}
bool testPassWord(char custPass[])
{
int numLetters, numDigits, length;
length = strlen(custPass);
numLetters = countLetters(custPass);
numDigits = countDigits(custPass);
if (numLetters == 5 && numDigits == 3 && length == 8 )
return true;
else
return false;
}
int countLetters(char *strPtr)
{
int occurs = 0;
while(*strPtr != '\0')
{
if (isalpha(*strPtr))
{
occurs++;
strPtr++;
}
}
return occurs;
}
int countDigits(char *strPtr)
{
int occurs = 0;
while(*strPtr != '\0')
{
if (isdigit(*strPtr))
{
occurs++;
strPtr++;
}
}
return occurs;
}
Enter a password consisting of exactly 5 letters and 3 digits: kayle123
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started