You are on page 1of 4

#include 

<stdio.h>
#include <stdlib.h>
#include <time.h>

// iResp variables for input values
int iResp1 = 0;
int iResp2 = 0;
int iResp3 = 0;
int iResp4 = 0;
int iResp5 = 0;

// i variables for random values
int i1 = 0;
int i2 = 0;
int i3 = 0;
int i4 = 0;
int i5 = 0;

// for time
int elasped = 0;
int current = 0;

// creating void for easy, intermediate & difficult
void easy();         // for easy fuction prototype
void intermediate(); //for intermediate function prototype
void difficult();    //for difficult function prototype

// Defining the main fuction
int main()
{
    int iSelection = 0;
    srand(time(NULL)); // making the value null for time and random numbers
    printf("\n\t~ ~ ~ CONCENTRATION GAME ~ ~ ~\n");
    // Creating a do-while loop
    do
    {
        // Displaying Menu
        printf("\n1. Easy Level (3 numbers in 5 seconds)\n");
        printf("2. Intermidiate Level (5 numbers in 4 seconds)\n");
        printf("3. Difficult Level (5 numbers in 2 seconds)\n");
        printf("4. Quit\n");
        printf("\nEnter your selection : ");
        scanf("%d", &iSelection);
        // Creating swith for the selections
        switch (iSelection)
        {
        case 1:
            easy();
            break;
        case 2:
            intermediate();
            break;
        case 3:
            difficult();
            break;
        }
    } while (iSelection != 4); // end do-while loop
}

// Defining void for easy level
void easy()
{
    int eResponse = 0;
    // giving i variables a random value
    i1 = rand() % 100;
    i2 = rand() % 100;
    i3 = rand() % 100;

    printf("\nConcentrate on these three Numbers");
    printf("\n%d\t%d\t%d\n", i1, i2, i3);

    current = time(NULL); // Current time null
    do
    {
        elasped = time(NULL); // Elasped time null
    } while ((elasped - current) < 5);

    system("cls"); // Clearing the system

    printf("Enter each number seperated by space : ");
    scanf("%d%d%d", &iResp1, &iResp2, &iResp3);
    // Creating if-else statements for checking values
    if (iResp1 == i1 && iResp2 == i2 && iResp3 == i3)
    {
        printf("\nCONGRATULATIONS !!! YOU WON !!!\n\n\n");
    }
    else
    {
        printf("\nSorry correct numbers were %d %d %d\n\n\n", i1, i2, i3);
    }
    // Continuing at the same level or different
    printf("1. Continue at this level\n");
    printf("2. Choose different level\n");
    printf("\nEnter your response : ");
    scanf("%d", &eResponse);
    if (eResponse == 1)
    {
        easy(); // Calling the easy void
    }
}

void intermediate()
{
    // giving i variables a random value
    int eResponse = 0;
    i1 = rand() % 100;
    i2 = rand() % 100;
    i3 = rand() % 100;
    i4 = rand() % 100;
    i5 = rand() % 100;

    printf("\nConcentrate on these three Numbers");
    printf("\n%d\t%d\t%d\t%d\t%d\n", i1, i2, i3, i4, i5);

    current = time(NULL); // Current time null
    do
    {
        elasped = time(NULL); // Elasped time null
    } while ((elasped - current) < 4);

    system("cls"); // Clearing the system

    printf("Enter each number seperated by space : ");
    scanf("%d%d%d%d%d", &iResp1, &iResp2, &iResp3, &iResp4, &iResp5);
    // Creating if-else statements for checking values
    if (iResp1 == i1 && iResp2 == i2 && iResp3 == i3 && iResp4 == i4 && iResp5 
== i5)
    {
        printf("\nCONGRATULATIONS !!! YOU WON !!!\n\n\n");
    }
    else
    {
        printf("\nSorry correct numbers were %d %d %d %d %d\n\n\n", i1, i2, i3
, i4, i5);
    }
    // Continuing at the same level or different
    printf("1. Continue at this level\n");
    printf("2. Choose different level\n");
    printf("\nEnter your response : ");
    scanf("%d", &eResponse);
    if (eResponse == 1)
    {
        intermediate(); // Calling the intermediate void
    }
}

void difficult()
{
    int eResponse = 0;
    // giving i variables a random value
    i1 = rand() % 100;
    i2 = rand() % 100;
    i3 = rand() % 100;
    i4 = rand() % 100;
    i5 = rand() % 100;

    printf("\nConcentrate on these three Numbers");
    printf("\n%d\t%d\t%d\t%d\t%d\n", i1, i2, i3, i4, i5);

    current = time(NULL); // Current time null
    do
    {
        elasped = time(NULL); // Elasped time null
    } while ((elasped - current) < 2);

    system("cls"); // Clearing the system

    printf("Enter each number seperated by space : ");
    scanf("%d%d%d%d%d", &iResp1, &iResp2, &iResp3, &iResp4, &iResp5);
    // Creating if-else statements for checking values
    if (iResp1 == i1 && iResp2 == i2 && iResp3 == i3 && iResp4 == i4 && iResp5 
== i5)
    {
        printf("\nCONGRATULATIONS !!! YOU WON !!!\n\n\n");
    }
    else
    {
        printf("\nSorry correct numbers were %d %d %d %d %d\n\n\n", i1, i2, i3
, i4, i5);
    }
    // Continuing at the same level or different
    printf("1. Continue at this level\n");
    printf("2. Choose different level\n");
    printf("\nEnter your response : ");
    scanf("%d", &eResponse);
    if (eResponse == 1)
    {
        difficult(); // Calling the difficult void
    }
}

You might also like