You are viewing a single comment's thread. Return to all comments →
int main() { int a, b; scanf("%d\n%d", &a, &b); // Complete the code. char *nums[9] = {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine"}; for(int i = a; i <= b; i++){ if(i > 0 && i < 10) printf("%s\n", nums[i-1]); else{ if(i % 2 == 0) printf("even\n"); else printf("odd\n"); } } return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
For Loop in C
You are viewing a single comment's thread. Return to all comments →
include
include
include
include
int main() { int a, b; scanf("%d\n%d", &a, &b); // Complete the code. char *nums[9] = {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine"}; for(int i = a; i <= b; i++){ if(i > 0 && i < 10) printf("%s\n", nums[i-1]); else{ if(i % 2 == 0) printf("even\n"); else printf("odd\n"); }
}
return 0; }