Random


SUBMITTED BY: Guest

DATE: Dec. 23, 2013, 12:24 a.m.

FORMAT: C++

SIZE: 711 Bytes

HITS: 6780

  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. using namespace std;
  5. int main()
  6. {
  7. int i,j;
  8. int ctr(0);
  9. srand(time(0));
  10. i = rand() % 6 + 1;
  11. do{
  12. cout << "Masukkan tebakan angka: ";
  13. cin >> j;
  14. if (j > i)
  15. cout << "Angka terlalu BESAR\n";
  16. else if (j == i)
  17. {
  18. cout << "JAWABAN BENAR!\n";
  19. break;
  20. }
  21. else
  22. cout << "Angka terlalu KECIL\n";
  23. ctr++;
  24. } while(ctr < 3);
  25. if (ctr == 3)
  26. cout << "kok bodo sih!!?";
  27. return 0;
  28. }

comments powered by Disqus