in

NUMBER GUESSING GAME_ C PROGRAMMING

#include <stdio.h>

int main()

{

    int num, guess, tries = 0;

    srand(time(0)); /* seed random number generator */

    num = rand() % 100 + 1; /* random number between 1 and 100 */

    printf(“Guess My Number Gamenn”);

    do

    {

        printf(“Enter a guess between 1 and 100 : “);

        scanf(“%d”, &guess);

        tries++;

        if (guess > num)

        {

            printf(“Too high!nn”);

        }

        else if (guess < num)

        {

            printf(“Too low!nn”);

        }

        else

        {

            printf(“nCorrect! You got it in %d guesses!n”, tries);

        }

    }while (guess != num);

    return 0;

}

This post was created with our nice and easy submission form. Create your post!

What do you think?

Written by Tamojit-Das

Comments

Leave a Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Loading…

0

GitHub Arctic Code Vault

FILM REVIEW_Bollywood_Hichki