482,994 views
25 votes
25 votes
Write a c program to display even numbers from 10 to 20 in descending order​

User KanisXXX
by
2.9k points

2 Answers

29 votes
29 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 Agbinfo
by
2.4k points
21 votes
21 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

User Arqam
by
3.1k points