An algorithm to calculate even numbers between 0 and 99
Answers
Answered by
8
Answer:
using loop from 0 to 99
for (int i = 0; i < 99; i++) {
if(i%2==0)
{
cout<<i<<" ";
}
}
Step-by-step explanation:
Answered by
3
Basic programming
Step-by-step explanation:
So the basic logic to find even numbers is that if we divide the number by 2 the remainder should be 0.
Step 1 - Start.
Step 2 - I = 0.
Step 3 - Accept the numbers.
Step 4 - while(i<=100)
if(number % 2 == 0)
display the number
Step 5 - End.
Below is the program to execute the algorithm
#include <iostream>
using namespace std;
int main() {
int n;
cout << "Enter an integer: ";
cin >> n;
if ( n % 2 == 0)
cout << n << "Number is even.";
else
cout << n << "Number is odd.";
return 0;
}
Similar questions