Program to add only positive numbers.

Program to add only positive numbers.


#include <iostream>
using namespace std;
int main()
{

int n;
cin >> n;
int i = 1;
int sum = 0;

while (n >= i)
{

sum = sum + i;
i++;
}
cout << sum << endl;

return 0;
}

 

Post a Comment

[blogger]

Author Name

Contact Form

Name

Email *

Message *

Powered by Blogger.