Create a Guess Game

This is the place for ALL of the user submitted challenges. If you create a little challenge/mission/riddle/whatever, post it here.
Forum rules
Do not post missions that you did NOT create without proper citing.

Re: Create a Guess Game

Post by VvGHOSTvV on Sun Oct 04, 2015 9:34 am
([msg=89957]see Re: Create a Guess Game[/msg])

Code: Select all

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <math.h>


main()

{
    int x;
    int i;
    int guess;
    int a;

    i = 5;
    a = 0;

    srand (time(NULL));

    x = (rand()%15) +1;

    while(a!=i){
    a++;
    printf("take a guess \n");
    scanf("%d", &guess);
    printf("attempt = %d \n you entered %d \n", a, guess);

    if(guess==x){
        printf("YOU WIN \n");
        break;
    }
    else if(abs(x-guess)<=2){
        printf("\nhot\n");
    }
    else if(abs(x-guess)<=5){
        printf("\nwarm\n");
    }
    else
        printf("cold\n");
}
    printf("Game Over, the answer was %d", guess);
}

"In our country we have a problem, the government"
User avatar
VvGHOSTvV
New User
New User
 
Posts: 47
Joined: Thu Jul 19, 2012 7:09 pm
Location: Oklahoma
Blog: View Blog (0)


Previous

Return to User Submitted

Who is online

Users browsing this forum: No registered users and 0 guests