Advertisement
Guest User

Untitled

a guest
Jun 27th, 2021
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. void main()
  6. {
  7. int n;
  8. int zbir = 0;
  9.  
  10. cout << "Unesi broj n: " << endl;
  11. cin >> n;
  12.  
  13. if (n > 20)
  14. {
  15. cout << "Broj n ne smije biti veci od 20" << endl;
  16. system("PAUSE");
  17. }
  18.  
  19. for (int i = 1; i <= n; i++)
  20. {
  21. zbir += i * i;
  22. }
  23.  
  24. cout << "Zbir kvadrata niza je: " << zbir << endl;
  25. system("PAUSE");
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement