Created
June 23, 2024 15:09
-
-
Save Andrej123456789/d2da9705434b93c5b6e2875a8e7e6623 to your computer and use it in GitHub Desktop.
DOS Showdown game 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <time.h> | |
#include <stdlib.h> | |
int main() | |
{ | |
char input[3]; | |
int input_number; | |
int generated_number; | |
srand(time(NULL)); | |
generated_number = rand() % 20; | |
printf("Guess a number (0 - 19): "); | |
scanf("%2s", input); | |
input_number = atoi(input); | |
if (input_number == generated_number) | |
{ | |
printf("You won!\r\n"); | |
} | |
else | |
{ | |
printf("You lost!\r\n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment