We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- C
- Conditionals and Loops
- For Loop in C
- Discussions
For Loop in C
For Loop in C
Sort by
recency
|
827 Discussions
|
Please Login in order to post a comment
void check_digit(int x) { if ((x >= 1) && (x <= 9)) { if (x == 1) { puts("one"); } else if (x == 2) { puts("two"); } else if (x == 3) { puts("three"); } else if (x == 4) { puts("four"); } else if (x == 5) { puts("five"); } else if (x == 6) { puts("six"); } else if (x == 7) { puts("seven"); } else if (x == 8) { puts("eight"); } else if (x == 9) { puts("nine"); } } if (x > 9) {
if ((x % 2) == 0) { puts("even"); } else { puts("odd"); } } }
int main() { int a, b; scanf("%d\n%d", &a, &b);
}
char arr[][10] = {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine"}; for (int i = a; i<=b; i++){ if (i<=9){ printf("%s\n", arr[i-1]); } else { printf(((i%2)==0)? "even\n": "odd\n"); } }