In: Computer Science
Write a program in C++ that computes the sum of odd numbers between 1 and 117. Execute the program and submit a screen capture of the program and its results.
Thanks for the question. Below is the code you will be needing. Let me know if you have any doubts or if you need anything to change.
If you are satisfied with the solution, please leave a +ve feedback : ) Let me know for any help with any other questions.
Thank You!
===========================================================================
#include<iostream>
using namespace std;
int main(){
const int START = 1;
const int END = 117;
int totalOddSum = 0;
for(int num = START; num <= END; num++){
if(num%2==1) totalOddSum +=
num;
}
cout<<"Sum of all odd numbers between
"<<START<< " and " <<END
<<" is
"<<totalOddSum<<endl;
return 0;
}