Answer to Question #291793 in C++ for barken

Question #291793

write an algorithm to calculate even numbers between 10 and 250


1
Expert's answer
2022-01-28T20:03:58-0500

1 Set count equal 0

2 Set num equal 10

3 If num is even add 1 to count

4 Add 1 to num

5 If num is less or equal 250 go to step 3

6 Return count


The realisation of the algorithm on C++:

#include <iostream>
using namespace std;

int main() {
    int count=0;

    for (int num=20; num<=250; num++) {
        if (num%2 == 0) {
            count++;
        }
    }
    cout << count;
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog