Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- // korisnikot ni vnesuva eden broj n, i sakame da go prestame zbirot od site broevi pomali ili ednakvi od N pocnuvajki od 1
- // N = 5, zbir = 1 + 2 + 3 + 4 + 5
- int N;
- cin >> N;
- int zbir = 0;
- int x = 1;
- int y = N;
- while(x <= y) {
- cout << x << " ";
- zbir += x;
- x += 1;
- }
- cout << endl;
- cout << zbir << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment