Advertisement
Zooby4456

C Wierd errors

Oct 26th, 2014
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.73 KB | None | 0 0
  1. /*
  2. Project: Concentration
  3. Description: The concentration game generates random numbers and displays them for short period of time for the user to memorize.
  4. During the time the random numbers are displayed, the player tries to memorize the number and their sequence.
  5. After a few seconds have passed, the computer screen is cleared and the user is asked to input the same numbers in the same sequence.
  6. */
  7. #include <stdio.h>
  8. #include <conio.h>
  9. #include <stdlib.h>
  10. #include <time.h>
  11. int main()
  12. {
  13.    // Declarations
  14.    char cYesNo = 'z';
  15.    int guessNum1 = 0;
  16.    int guessNum2 = 0, guessNum3 = 0;
  17.    int randNuml = 0, randNum2 = 0, randNum3 = 0;
  18.    int elapsedTime = 0;
  19.    int currentTime = 0;
  20.    int counter = 0;
  21.    srand(time(NULL));
  22.    // Input, Process, Output
  23.    printf("Play a game of Concentration? (y or n): ");
  24.    scanf("%c", &cYesNo);
  25.    
  26.    if(cYesNo == 'y' cYesNo == 'Y')
  27.    {
  28.      
  29.       randNuml = rand() % 100;
  30.       randNum2 = rand() % 100;
  31.       randNum3 = rand() % 100;
  32.       printf("\nConcentrate on the next three numbers\n");
  33.       printf("\n\t%d %d %d\n\n", randNuml , randNum2, randNum3);
  34.      
  35.       currentTime = time(NULL);
  36.      
  37.       do{
  38.          elapsedTime = time(NULL);
  39.       }while ((elapsedTime - currentTime) < 3);
  40.      
  41.       system("cls");
  42.      
  43.       printf("\nEnter each # separated with one space: ");
  44.       scanf("%d%d%d", &guessNum1, &guessNum2, &guessNum3);
  45.      
  46.       if(randNuml == guessNum1 && randNum2 == guessNum2 && randNum3 == guessNum3)
  47.          printf("\nCongratulations!\n");
  48.       else
  49.          printf("\nSorry, correct numbers were: %d %d %d\n", randNuml, randNum2, randNum3);
  50.    }
  51.    printf("\nPress any key to quit");
  52.    getch();
  53.    return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement