Advertisement
naser2345

Untitled

Oct 12th, 2020 (edited)
2,126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.95 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int checkAns(char c)
  4. {
  5.     switch (c){
  6.         case 'y':
  7.             return 1;
  8.             break;
  9.         case 'n':
  10.             return 0;
  11.             break;
  12.         default:
  13.             printf("INVALID OUTPUT\n");
  14.             exit(404);
  15.     }
  16. }
  17.  
  18. int main()
  19. {
  20.     char ans;
  21.     printf("Do you have a fever? ");scanf(" %c", &ans); //Q1
  22.     if (checkAns(ans)){
  23.         printf("Do you have a sore throat and headache-without nasal drainage? ");scanf(" %c", &ans); //Q2
  24.         if (checkAns(ans)){
  25.             printf("STREP THROAT\n");
  26.         }else{
  27.             printf("Did your symptoms start suddenly, and do you have a combination of symptoms including muscle aches, chills, a sore throat, runny nose or cough? ");scanf(" %c", &ans); //Q3
  28.             if (checkAns(ans)){
  29.                 printf("FLU\n");
  30.             }else{
  31.                 printf("Do you have a runny and/or itchy nose, sneezing, and itchy eyes? ");scanf(" %c", &ans); //Q4
  32.                 if (checkAns(ans)){
  33.                     printf("ALLERGIES\n");
  34.                 }else{
  35.                      printf("Do you have sneezing, a sore throat, headache, congestion and a runny nose? ");scanf(" %c", &ans); //Q5
  36.                      if (checkAns(ans)){
  37.                          printf("COLD\n");
  38.                      }else{
  39.                          printf("Call Your Doctor\n");
  40.                      }
  41.                 }
  42.             }
  43.         }
  44.        
  45.     }else{
  46.         printf("Do you have a runny and/or itchy nose, sneezing, and itchy eyes? ");scanf(" %c", &ans); //Q4
  47.         if (checkAns(ans)){
  48.             printf("ALLERGIES\n");
  49.         }else{
  50.              printf("Do you have sneezing, a sore throat, headache, congestion and a runny nose? ");scanf(" %c", &ans); //Q5
  51.              if (checkAns(ans)){
  52.                  printf("COLD\n");
  53.              }else{
  54.                  printf("Call Your Doctor\n");
  55.              }
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement