Facebook
From Shakil, 4 Years ago, written in C.
Embed
Download Paste or View Raw
Hits: 254
  1.  
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <conio.h>
  6.  
  7. char* ques[] = {"Hi","How are you?","What is your name?", "What is the capital of Bangladesh?"};
  8. char* ans[] = {"Hello!","I am fine","It's sss and you?","The capital of Bangladesh is Dhaka"};
  9.  
  10.  
  11. void talk_func(void);
  12.  
  13. char human_talks[150];
  14. char cont;
  15.  
  16.  
  17. int main()
  18. {
  19.    
  20.     printf("Assalamu alaikum\n");
  21.     printf("I am a CHATBOT\n");
  22.     printf("I can converse with you...\n");
  23.  
  24.  
  25.  
  26. talk_func();
  27.  
  28.     return 0;
  29. }
  30.  
  31.  
  32.  
  33.  
  34. void talk_func(void)
  35. {
  36.  
  37. do {
  38.  
  39.         printf("Enter");
  40.         scanf("%[^\n]", &human_talks);
  41.         int i =0;
  42.         for (i = 0;;i++){
  43.  
  44.         if (strcmp(ques[i],human_talks)==0)
  45.             {
  46.            printf("%s\n", ans[i]);
  47.  
  48.             }
  49.         printf("Wanna ask something again?\n");
  50.  
  51.     cont = getch();
  52.  
  53.  
  54.  
  55.     }
  56.  
  57.     }
  58.     while ( cont == 'y');
  59.     getch();
  60.  
  61.     return 0;
  62. }
  63.