Wap to accept numbers from the user until he/she enters a negative number or zero.Calculate and print the Sum of even numbers and count the total number of odd numbers using do while loop
Answers
Answered by
0
Answer:
#include <iostream>
using namespace std;
int main()
{
int n, sum = 0;
cout << "Enter a positive integer: ";
cin >> n;
for (int i = 1; i <= n; ++i) {
sum += i;
}
cout << "Sum = " << sum;
return 0;
}
Similar questions