-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoops.c
More file actions
36 lines (30 loc) · 673 Bytes
/
Loops.c
File metadata and controls
36 lines (30 loc) · 673 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Question link - https://www.hackerrank.com/challenges/for-loop-in-c/problem?isFullScreen=true
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main()
{
int a, b;
scanf("%d\n%d", &a, &b);
// Complete the code.
char numberStrings[9][20] = {
"one",
"two",
"three",
"four",
"five",
"six",
"seven",
"eight",
"nine"
};
for (int i = a; i <= b; i++){
if (i >= 0 && i <= 9){
printf("%s\n", numberStrings[i - 1]);
}else {
printf("%s\n" , (i % 2 == 0) ? "even" : "odd");
}
}
return 0;
}