Skip to content

Instantly share code, notes, and snippets.

@Andrej123456789
Created June 23, 2024 15:09
Show Gist options
  • Save Andrej123456789/d2da9705434b93c5b6e2875a8e7e6623 to your computer and use it in GitHub Desktop.
Save Andrej123456789/d2da9705434b93c5b6e2875a8e7e6623 to your computer and use it in GitHub Desktop.
DOS Showdown game 1
#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