Facebook
From Shakil, 1 Year ago, written in C.
Embed
Download Paste or View Raw
Hits: 202
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <conio.h>
  5.  
  6. char* ques[] = {"Hi","How are you?","What is your name?", "What is the capital of Bangladesh?"};
  7. char* ans[] = {"Hello!","I am fine","It's sss and you?","The capital of Bangladesh is Dhaka"};
  8.  
  9.  
  10. char human_talks[150];
  11. char cont;
  12.  
  13.  
  14. int main()
  15. {
  16.  
  17. do {
  18.  
  19.         printf("Ask : ");
  20.         scanf("%[^\n]", &human_talks);
  21.         int i =0;
  22.         for (i = 0; ;i++)
  23.             {
  24.  
  25.         if (strcmp(ques[i],human_talks)==0)
  26.             {
  27.            printf("Ans : %s\n", ans[i]);
  28.             break;
  29.             }
  30.     }
  31.     cont = getch();
  32. }
  33.   while ( cont == 'y');
  34.     getch();
  35.  
  36.     return 0;
  37. }
  38.  
  39.