Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream.h>
- #include <conio.h>
- void main()
- {
- clrscr();
- unsigned int n,sum(0);
- cout << "Enter a number: ";
- cin >> n;
- for (int i(1); i<=n; i++)
- sum+=i;
- cout << "\n\nSum of nos. from 1 to " << n << " is " << sum << endl;
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement