fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. // Password
  7. string password;
  8. cout << "Enter password: ";
  9. cin >> password;
  10.  
  11. if (password == "1234") {
  12. cout << "Access Granted\n";
  13. } else {
  14. cout << "Access Denied\n";
  15. }
  16.  
  17.  
  18. // Even/Odd
  19. int num;
  20. cout << "Enter a number: ";
  21. cin >> num;
  22.  
  23. if (num % 2 == 0) {
  24. cout << num << " is Even\n";
  25. } else {
  26. cout << num << " is Odd\n";
  27. }
  28.  
  29.  
  30. // Grade
  31. int marks;
  32. cout << "Enter marks: ";
  33. cin >> marks;
  34.  
  35. if (marks >= 90) cout << "Grade: A";
  36. else if (marks >= 80) cout << "Grade: B";
  37. else if (marks >= 70) cout << "Grade: C";
  38. else if (marks >= 60) cout << "Grade: D";
  39. else cout << "Grade: F";
  40. cout << endl;
  41.  
  42. // Traffic Light
  43. char light;
  44. cout << "Enter traffic light color (R/Y/G): ";
  45. cin >> light;
  46.  
  47. switch (light) {
  48. case 'R':
  49. cout << "Stop";
  50. break;
  51. case 'Y':
  52. cout << "Slow down";
  53. break;
  54. case 'G':
  55. cout << "Go";
  56. break;
  57. default:
  58. cout << "Invalid color";
  59. }
  60. cout << endl;
  61.  
  62. // ATM
  63. int pin, balance = 5000, withdraw;
  64. cout << "Enter PIN: ";
  65. cin >> pin;
  66.  
  67. if (pin == 1234) {
  68. cout << "Enter amount to withdraw: ";
  69. cin >> withdraw;
  70.  
  71. if (withdraw <= balance)
  72. cout << "Please take your cash\n";
  73. else
  74. cout << "Insufficient balance\n";
  75. } else {
  76. cout << "Incorrect PIN\n";
  77. }
  78.  
  79.  
  80. return 0;
  81. }
Success #stdin #stdout 0.01s 5316KB
stdin
2314
4
85
G
1234
6000
stdout
Enter password: Access Denied
Enter a number: 4 is Even
Enter marks: Grade: B
Enter traffic light color (R/Y/G): Go
Enter PIN: Enter amount to withdraw: Insufficient balance