Question: C++: Please provide a multi-line comment ( /* */ ) for the source code below: #include using namespace std; // Global constants const int SIZE

C++: Please provide a multi-line comment ( /* */ ) for the source code below:

#include

using namespace std;

// Global constants

const int SIZE = 80; // The maximum size of the array

const int MIN = 6; // The minimum number characters

// Function prototypes

void displayRequirements();

void displayResult(char[]);

int main()

{

char cstring[SIZE];

displayRequirements();

cout << "Enter a password: ";

cin.getline(cstring, SIZE);

displayResult(cstring);

return 0;

}

void displayRequirements()

{

// Display the password requirements.

cout << "Password Requirments: "

<< " - The password should be at least "

<< MIN << " characters long. "

<< " - The password should contain at least one uppercase "

<< " and at least one lowercase letter. "

<< " - The password should have at least one digit. ";

}

void displayResult(char str[])

{

bool length, upper, lower, digit;

length = upper = lower = digit = false;

int lengthCount = 0;

while(str[lengthCount]!='\0'){

if(str[lengthCount]>='A' && str[lengthCount]<='Z')

upper = true;

else if(str[lengthCount]>='a' && str[lengthCount]<='z')

lower = true;

else if(str[lengthCount]>='0' && str[lengthCount]<='9')

digit = true;

lengthCount++;

}

if(lengthCount>=MIN)

length = true;

if(!length || !upper || !lower || !digit){

cout<<"The password should be"<

if(!length)

cout<<"At least 6 characters"<

if(!upper)

cout<<"At least one uppercase"<

if(!lower)

cout<<"At least one lowercase letter"<

if(!digit)

cout<<"At least one digit"<

}

else{

cout<<"The password is OK!"<

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!