- #include<iostream>
- using namespace std;
- double suma(int a) {
- int zbroj = 0;
- for (int i = 1; i <= a; i++) {
- zbroj = zbroj + i;
- }
- return zbroj;
- }
- int main() {
- int broj1;
- cout << "Upisite broj: ";
- cin >> broj1;
- cin.ignore();
- cout << "Suma brojeva od 1 do " << broj1 << " je " << suma(broj1);
- cout << endl;
- return 0;
- }