My code below accepts input up to 5 numbers only. It only counts the odd numbers then sums up the total. What I need to add is a continue statement that will skip and not count the number 7, if entered. I need to take another copy of that code but instead of putting in the continue statement, use a break that will exit the program if the number 7 is entered. I also must use a for loop which I have below. (Any help is appreciated)
I have tried inserting:
Code:
if(counter==7)
continue;
and
if(counter==7)
break;
Code:
#include <iostream>
using namespace std;
int main() {
int sum = 0;
int num[5];
for (int counter = 0; counter < 5; counter++) {
cout << "Enter a Number: ";
cin >> num[counter];
if (num[counter] % 2 != 0)
sum = sum + num[counter];
}
cout << "Sum of Odd Numbers is: " << sum << endl;
system("pause");
return 0;
}