Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. // Jozef Murgaš
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5.  
  6.  
  7. int main()
  8. {
  9. int random_cislo=0,count=0,num;
  10.  
  11. //random vygenerované číslo od 0po10
  12. random_cislo=rand()%10;
  13.  
  14. //infinite slučka
  15. while(1)
  16. {
  17. //čítanie čísla uživatela
  18. printf("\n\nUhádni číslo od 0-10 ");
  19. scanf("%d",&num);
  20.  
  21. //Porovnávanie zadaného čísla s vygenerovaným
  22.  
  23. if(random_cislo==num){
  24. printf("Správana odpoveď");
  25. break;
  26. }
  27. else if(random_cislo<num){
  28. printf("Číslo je menšie ako ktoré si zadal");
  29. }
  30. else if(random_cislo>num){
  31. printf("Číslo je väčšie ako ktoré si zadal");
  32. }
  33.  
  34. }
  35.  
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement