Write a for loop that counts only the odd numbers out of


Here are two examples:

if(counter==7)

continue;

if(counter==7)

break;

1. Write a for loop that counts only the odd numbers out of the first five numbers entered from the keyboard, but does not count (skips) the number 7. Use the keyword continue to skip 7 inside the loop

2. Write the same program above, but exit the for loop using break if the number 7 is entered.

#include

using namespace std;

intmain() {

                int sum = 0;

                intnum[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 <

                system("pause");

                return 0;

}

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Write a for loop that counts only the odd numbers out of
Reference No:- TGS01591041

Expected delivery within 24 Hours