Skip to content

vikasvika/Vicky-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

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

int main() { int number, guess, attempts = 0;

// Generate a random number between 1 and 100
srand(time(0));
number = rand() % 100 + 1;

printf("Welcome to the Guessing Game!\n");
printf("I have chosen a number between 1 and 100.\n");

do {
    printf("Enter your guess: ");
    scanf("%d", &guess);
    
    attempts++;
    
    if (guess > number) {
        printf("Too high! Try again.\n");
    } else if (guess < number) {
        printf("Too low! Try again.\n");
    } else {
        printf("Congratulations! You guessed the number in %d attempts.\n", attempts);
    }
} while (guess != number);

return 0;

}

About

git repository

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published