Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- int main(void) {
- srand(time(NULL));
- int r = rand() % 10 + 1;
- int correct = 0;
- int guess;
- int counter = 0;
- printf("Pogodi moj broj! ");
- do {
- scanf("%d", &guess);
- if (guess == r) {
- counter++;
- printf("Tacno ste pogodili u %d pokusaja! Cestitamo!\n", counter);
- correct = 1;
- }
- if (guess < r) {
- counter++;
- printf("Dali ste prenizak broj. Pokusajte ponovo. ");
- }
- if (guess > r) {
- counter++;
- printf("Dali ste previsok broj. Pokusajte ponovo. ");
- }
- } while (correct == 0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement