fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int age;
  6.  
  7. // รับข้อมูลอายุจากผู้ใช้
  8. cout << "กรุณากรอกอายุของคุณ: ";
  9. cin >> age;
  10.  
  11. // ตรวจสอบอายุ
  12. if (age < 12) {
  13. cout << "คุณยังเป็นเด็กอยู่" << endl;
  14. }
  15. else if (age >= 12 && age < 18) {
  16. cout << "คุณเป็นวัยรุ่น" << endl;
  17. }
  18. else if (age >= 18 && age < 60) {
  19. cout << "คุณเป็นผู้ใหญ่" << endl;
  20. }
  21. else {
  22. cout << "คุณเป็นผู้สูงอายุ" << endl;
  23. }
  24.  
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
กรุณากรอกอายุของคุณ: คุณเป็นผู้สูงอายุ