// Expression: [A-Z a-z 0-9]+ #include #include using namespace std; int main() { while (true) { string input; bool isValid = false; cout << "Enter an expression : "; getline(cin, input); for (int i = 0; i < input.length(); i++) { if (isalnum(input[i])) isValid = true; else { isValid = false; break; } } if (isValid) cout << "Valid" << endl; else cout << "Invalid" << endl; cout << endl; } }