94.5k views
18 votes
Write a c program to display even numbers from 10 to 20 in descending order​

2 Answers

9 votes

CODE

#include <stdio.h>

int main() {

for(int i = 20; i >= 10; i = i - 1) {

if(i%2 == 0) {

printf("%d,",i);

}

}

return 0;

}

DISPLAY

20,18,16,14,12,10,

EXPLANATION

The integer starts at 20 and goes down by 1 point to 10.

The if statement checks if the remainder of i is 0 to print the even numbers only.

User Sudhir Jangam
by
4.7k points
2 votes

Answer:

#include <stdio.h>

int main(){

for (int i = 10; i < 21; i+=2){

printf("%d\\", i);

}

return 0;

}

Step-by-step explanation:

i+=2 increments i by 2 starting with 10 so it prints out only even number

s

i < 21 because we also want to print out 20