Inactive Tutor answered 09/30/20
using namespace std;
#include <iostream>
int main()
{
int N=-1;
while (N<3)
{
cout << " Input positive integer N :>";
cin >> N;
}
int x=2;
long sum=0;
while (x<N)
{
sum += x;
x+=2;
}
cout << sum << endl;
}
Bob R.
asked 09/29/20Write a program that reads an integer and prints the sum of all even integers between 2 and the input value, inclusive.
I have uploaded a image of my program to google drive.
https://drive.google.com/file/d/1cUZn4f_9bPIyPD6f-Vl80Y-GJfnIy596/view?usp=sharing
Any help will be greatly appreciated.
Inactive Tutor answered 09/30/20
using namespace std;
#include <iostream>
int main()
{
int N=-1;
while (N<3)
{
cout << " Input positive integer N :>";
cin >> N;
}
int x=2;
long sum=0;
while (x<N)
{
sum += x;
x+=2;
}
cout << sum << endl;
}
Get a free answer to a quick problem.
Most questions answered within 4 hours.
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.