#include <stdio.h>
int main() {
int a, b;
scanf("%d %d", &a, &b);
for (int n = a; n <= b; n++) {
if (n == 1) {
printf("one\n");
} else if (n == 2) {
printf("two\n");
} else if (n == 3) {
printf("three\n");
} else if (n == 4) {
printf("four\n");
} else if (n == 5) {
printf("five\n");
} else if (n == 6) {
printf("six\n");
} else if (n == 7) {
printf("seven\n");
} else if (n == 8) {
printf("eight\n");
} else if (n == 9) {
printf("nine\n");
} else {
if (n % 2 == 0) {
printf("even\n");
} else {
printf("odd\n");
}
}
}
return 0;
}
Let's go through the solution step by step:
We include the
In the main() function, we declare two integers a and b to store the input values.
We use the scanf() function to read input from the user and store it in the variables a and b.
We use a for loop to iterate over the range from a to b. The loop variable n is initialized to a, and the loop continues as long as n is less than or equal to b. In each iteration, n is incremented by 1.
Within the for loop, we use a series of if-else if statements to check the value of n against different conditions.
If n is equal to 1, 2, 3, ..., 9, we print the corresponding word ("one", "two", "three", ..., "nine") using the printf() function.
If n is not equal to any of the values 1 to 9, we further check if n is even or odd using the modulus operator (%). If n is divisible by 2 (i.e., n % 2 == 0), we print "even". Otherwise, we print "odd".
The loop continues until n reaches the value of b, and the actions within the loop are repeated accordingly.