/* 샘플 코드 10 */
#include <iostream>
using namespace std;
int main() {
int x;
cout << "Enter a number :";
cin >> x;
if (x < 10) {
cout << "You Entered a valve less than 10" << endl;
}
}
/* 샘플 코드 11 */
#include <iostream>
using namespace std;
int main() {
int num;
cout << "Enter a number :";
cin >> num;
if (num < 0) {
cout << "You entered a negative number\n";
}
else {
cout << "You entered a non-negative number\n";
}
}
/* 샘플 코드 12 */
#include <iostream>
using namespace std;
int main() {
int num;
cout << "Enter a number :";
cin >> num;
if (num < 0) {
cout << "You entered a negative number\n";
}
else if (num == 0) {
cout << "You entered zero\n";
}
else {
cout << "You entered a non-negative number\n";
}
}
/* 샘플 코드 13 */
#include <iostream>
#include <string>
using namespace std;
int main() {
string password;
cout << "Enter your password : " << endl;
getline(cin, password, '\n');
if (password == "xyzzy") {
cout << "Access allowed" << "\n";
}
else {
cout << "Bad password , Denide access!" << "\n";
return 0;
}
}
/* 샘플 코드 14 */
#include <iostream>
#include <string>
using namespace std;
int main() {
string password;
string username;
cout << "Enter your password :" << endl;
getline(cin, password, '\n');
cout << "Enter your username :" << endl;
getline(cin, username, '\n');
if (username == "root" && password == "xyzzy") {
cout << "Access allowed" << endl;
}
else {
cout << "Bad username or password. Denied access !" << endl;
return 0;
}
}