Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <time.h>
  3.  
  4. int main()
  5. {
  6. int broj, brojRand, brojPokusaja=0;
  7.  
  8. srand((unsigned int)time(NULL));
  9. brojRand=rand()%100+1;
  10.  
  11. printf("Izabran je broj izmedju 1 i 100. Pokusajte ga pogoditi (-1 za izlaz).\n");
  12.  
  13. do
  14. {
  15. printf("Unesite broj: ");
  16. scanf("%d", &broj);
  17.  
  18. if(broj>brojRand)
  19. printf("Manji!\n");
  20. else if(broj<brojRand)
  21. printf("Veci!\n");
  22. brojPokusaja++;
  23. }
  24. while((broj!=brojRand) && (broj!=-1));
  25.  
  26. if (brojPokusaja==1)
  27. printf("\nCestitam pogodili ste iz prvog pokusaja!\n");
  28. else
  29. printf("\nJednak!\nBroj ste pogodili nakon %d pokusaja.\n", brojPokusaja);
  30.  
  31. printf("Kraj igre.\n");
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement