fork download
  1. #include <iostream>
  2. #include <ctime>
  3. #include <cstdlib>
  4. using namespace std;
  5.  
  6. int losowanie()
  7. {
  8. return (std::rand()%7)+4;
  9. }
  10. int suma(){
  11. int i = 0;
  12. int suma = 0;
  13. do {
  14. tab[i] = losowanie();
  15.  
  16. cout << tab[i] << ", ";
  17. i++;
  18.  
  19. } while (i<999);
  20. i = 0;
  21. do {
  22. suma = suma + tab[i];
  23. i++;
  24. } while (i<999);
  25. return suma;
  26. }
  27.  
  28. int
  29. int main() {
  30. srand (time(NULL));
  31. int tab[999];
  32. suma();
  33. return 0;
  34. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int suma()’:
prog.cpp:14:4: error: ‘tab’ was not declared in this scope
    tab[i] = losowanie();
    ^~~
prog.cpp:22:18: error: ‘tab’ was not declared in this scope
    suma = suma + tab[i];
                  ^~~
prog.cpp: At global scope:
prog.cpp:29:10: error: two or more data types in declaration of ‘main’
 int main() {
          ^
stdout
Standard output is empty