#includeusing namespace std; int main() { string str1 = "hello"; string str2 = "world"; if (str1 == str2) { cout << "The strings are equal" << endl; } else { cout << "The strings are not equal" << endl; } return 0; }
#includeDescription: This code prompts the user to enter a password and compares the input string to a stored password using the string equals function. If the input matches the password, the loop ends and the message "Access granted" is displayed. If the input does not match, the loop continues and the message "Access denied" is displayed. Package/library: The string equals function is part of the C++ standard library, so it does not require any external package or library.using namespace std; int main() { string password = "1234"; string input; while (input != password) { cout << "Enter the password: "; cin >> input; if (input == password) { cout << "Access granted" << endl; } else { cout << "Access denied" << endl; } } return 0; }