Advertisement
NAbdulla

Name Guessing

Jun 9th, 2015
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.23 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4.  
  5. int main()
  6. {
  7.     system("Title ***Name Guessing***");
  8.     system("color 0A");
  9.     int i, j, k, l, n;
  10.     char ch, grid1[5][10], grid2[20][10], name[20];
  11.     strcpy(grid1[0], "AFKPUZ");
  12.     strcpy(grid1[1], "BGLQV.");
  13.     strcpy(grid1[2], "CHMRW-");
  14.     strcpy(grid1[3], "DINSX(");
  15.     strcpy(grid1[4], "EJOTY)");
  16.  
  17.     printf("\n\t****Welcome, we are going to guess your name, please co-operate****\n\n");
  18.     while(1){
  19.         printf("Please enter the containing column number of your name's spelling's letters one by one from next table:\n\n");
  20.         printf("Column No.%c\t1\t2\t3\t4\t5\n\n\t", 26);
  21.         for(i = 0; i < 7; i++){
  22.             for(j = 0; j < 5; j++){
  23.                 printf("\t%c", grid1[j][i]);
  24.             }
  25.             printf("\n\n\t");
  26.         }
  27.         printf("\tWhen your input ends, Enter NULL (press Ctrl+Z)\n\n\t\t");
  28.         k = 0;
  29.         while(scanf("%d", &i) != EOF){
  30.             strcpy(grid2[k], grid1[i-1]);
  31.             k++;
  32.             printf("\t\t");
  33.         }
  34.  
  35.         system("color 0E");
  36.         printf("\n\tYes!!! You have almost done.........\n\nNow, Please enter the containing column number of your name's spelling's letters one by one from the printed line:\n\n");
  37.         printf("\nColumn No.%c\t1\t2\t3\t4\t5\t6\n\n\t", 26);
  38.         l = 0;
  39.         for(i = 0; i < k; i++){
  40.             for(j = 0; j < 7; j++){
  41.                 printf("\t%c", grid2[i][j]);
  42.             }
  43.             //printf("enter the column No.%c", 26);
  44.             scanf("%d", &n);
  45.             name[l] = grid2[i][n-1];
  46.             l++;
  47.             printf("\n\n\t");
  48.         }
  49.         name[l] = '\0';
  50.         printf("\tI guess this is your name: %s\n", name);
  51.         printf("\n\n\t\tDo you want to continue?\n\t\t\tTo continue press 1\n\t\t\tTo terminate press any other key\n\t\t\t\t\t\t\t");
  52.         scanf("%d", &i);
  53.         if(i == 1){
  54.             system("cls");
  55.             system("color 0A");
  56.             printf("Let's go for another time...............\n\n");
  57.         }
  58.         else{
  59.             system("color 0F");
  60.             printf("Thank you! See you later.\nExiting................\n");
  61.             break;
  62.         }
  63.     }
  64.     return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement