Last active
January 7, 2025 12:49
-
-
Save JBlond/c8a9a9fe137c754972bb516cb06475e6 to your computer and use it in GitHub Desktop.
number-game
This file contains hidden or 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 <stdlib.h> | |
#include <time.h> | |
int myNumber = 0; | |
int tries = 0; | |
int zahl = 0; | |
int main() { | |
srand((unsigned int) time(0)); | |
myNumber = rand() % 100 + 1; | |
for (tries = 0; zahl != myNumber; ++tries) { | |
printf("Bitte gib eine Zahl von 1 bis 100 ein: \n"); | |
scanf_s("%d", &zahl); | |
if (zahl == myNumber) { | |
printf("Richtig geraten!!!\n"); | |
printf("Du hast %d Versuche gebraucht. \n", tries); | |
return 0; | |
} | |
else | |
{ | |
if (zahl < myNumber) { | |
printf("Deine Zahl ist zu klein\n"); | |
} | |
else | |
{ | |
printf("Deine Zahl ist zu gro\xe1\n"); | |
} | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment