Algorithm to print all even numbers below hundred in the descending order
Algorithm to print all even numbers below 100 in the descending order.
for i = 100 to 0 step -2 ; print i;
assuming you don't want to go on forever with the negative ones ...
To print all even numbers below 100 in descending order, you can follow these steps:
1. Set a variable `num` to 98 (the largest even number below 100).
2. Start a loop that continues while `num` is greater than or equal to 0.
3. Inside the loop, print the value of `num`.
4. Subtract 2 from `num` to go to the next even number.
5. Repeat steps 3 and 4 until `num` is less than 0.
Here's the algorithm in pseudocode:
```
num = 98
while num >= 0:
print num
num = num - 2
```
To print all even numbers below 100 in descending order, you can use the following algorithm:
1. Initialize a variable 'num' to 98. This is the largest even number below 100.
2. Start a loop that runs until 'num' becomes less than or equal to 0.
3. Inside the loop, check if the current value of 'num' is divisible by 2 (i.e., an even number). If it is, print the value of 'num'.
4. Decrease the value of 'num' by 2 in each iteration.
5. Repeat steps 3-4 until 'num' becomes less than or equal to 0.
Here is the algorithm in pseudo-code:
```
num = 98
while num > 0:
if num % 2 == 0:
print(num)
num -= 2
```
By following this algorithm, you will be able to print all even numbers below 100 in descending order.