Answer:
C++ program with step by step code explanation and output result is provided below.
Code & Explanation:
We are required to create a program to sum even numbers from 1 to 60 inclusive using a while loop.
#include <iostream>
using namespace std;
int main()
{
int sum=0; // variable to store the sum of even numbers
int index=1; // variable to count the number of times while loop runs
while(index <= 60) // while loop iterates until index is less or equal to 60
{
if(index%2==0) // to find out whether the number is even or not
sum=sum+index; // if the number is even add it to total sum
index=index+1; // increase the index by 1 to continue the while loop
}
cout<<"The sum of even numbers from 1 to 60 is: "<<sum<<endl;
// to print the total sum of even numbers from 1 to 60 inclusive
return 0;
}
Output:
The sum of even numbers from 1 to 60 is: 930