You are viewing a single comment's thread. Return to all comments →
int main() { int n,a, b; scanf("%d\n%d\n", &a, &b); scanf("%d\n", &n); //if(n>0) //{ for(int i=a; i<=b;i++) { switch(i) { case(1):printf("ONE"); break; case(2):printf("TWO"); break; case(3):printf("THREE"); break; case(4):printf("FOUR"); break; case(5):printf("FIVE"); break; case(6):printf("SIX"); break; case(7):printf("SEVEN"); break; case(8):printf("EIGHT"); break; case(9):printf("NINE"); break; } } //} else if(n%2==0) printf("even\n"); else { printf("\nodd"); } }
Can anyon tell me whats wrong with this getting only odd a answer c
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 →
int main() { int n,a, b; scanf("%d\n%d\n", &a, &b); scanf("%d\n", &n); //if(n>0) //{ for(int i=a; i<=b;i++) { switch(i) { case(1):printf("ONE"); break; case(2):printf("TWO"); break; case(3):printf("THREE"); break; case(4):printf("FOUR"); break; case(5):printf("FIVE"); break; case(6):printf("SIX"); break; case(7):printf("SEVEN"); break; case(8):printf("EIGHT"); break; case(9):printf("NINE"); break; }
} //} else if(n%2==0) printf("even\n"); else { printf("\nodd"); } }