I am working on a C++ program with the following instructions: Write a program t
ID: 3545974 • Letter: I
Question
I am working on a C++ program with the following instructions:
Write a program that requests a password and verifies that it is a valid password. To be valid the password must be at least six characters long and contain at least one digit. I can get it to verify the password is at least 6 characters long and contains at least one digit, but when I try to get it to validate both conditions are met and tell the user "Thank you that is a valid password", I keep getting an error that no operator "&&" matches these operands.
Explanation / Answer
#include<iostream>
#include<string>
using namespace std;
int main()
{
char str[6];
cout<<"Enter password"; // this will get password from user
cin>>str;
if((strlen(str)<6)||(isdigit(atoi(str)))) //this part will validate your requirements
cout<<"Pasword too short / Password must contain a digit"<<endl;
else
cout<<"Pasword Matched"<<endl;
system("pause");
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.