Hacker rank Challenges #006
Task
For each integer in the interval (given as input) :
- If , then print the English representation of it in lowercase. That is "one" for , "two" for , and so on.
- Else if and it is an even number, then print "even".
- Else if and it is an odd number, then print "odd".
Input Format
The first line contains an integer, .
The seond line contains an integer, .
Constraints
Output Format
Print the appropriate English representation,even
, or odd
, based on the conditions described in the 'task' section.
Note:
Sample Input
8
11
Sample Output
eight
nine
even
odd
Source Code :
#include <stdio.h>#include <string.h>#include <math.h>#include <stdlib.h>
void cal(n){ if (n==1){ printf("one"); }else if (n==2){ printf("two"); }else if (n==3){ printf("three"); }else if (n==4){ printf("four"); }else if (n==5){ printf("five"); }else if (n==6){ printf("six"); }else if (n==7){ printf("seven"); }else if (n==8){ printf("eight"); }else if (n==9){ printf("nine"); }else if (n%2 ==0){ printf("even"); }else{ printf("odd"); }
}
int main() { int a, b,i; scanf("%d\n%d", &a, &b); // Complete the code. if (a>=b){ for (i=0;i<=a-b;i++){ cal(a+i); printf("\n"); } } else{ for (i=0;i<=b-a;i++){ cal(a+i); printf("\n"); } } return 0;}
Comments
Post a Comment