HackerRank C- For Loop in C
For each integer n in the interval [a,b] (given as input) :
If 1<=n<=9, then print the English representation of it in lowercase. That is "one" for 1, "two" for 1 , and so on.
Else if n>9 and it is an even number, then print "even".
Else if n>9 and it is an odd number, then print "odd".
- #include <stdio.h>
- #include <string.h>
- #include <math.h>
- #include <stdlib.h>
-
-
-
- int main()
- {
- int a, b;
- int n=0;
- scanf("%d\n%d", &a, &b);
- for(n=a;n<=b;n++)
- {
- if(n==1)
- {
- printf("one\n");
- }
- if(n==2)
- {
- printf("two\n");
- }
- if(n==3)
- {
- printf("three\n");
- }
- if(n==4)
- {
- printf("four\n");
- }
- if(n==5)
- {
- printf("five\n");
- }
- if(n==6)
- {
- printf("six\n");
- }
- if(n==7)
- {
- printf("seven\n");
- }
- if(n==8)
- {
- printf("eight\n");
- }
- if(n==9)
- {
- printf("nine\n");
- }
- if(n>9)
- {
- if(n%2==0)
- {
- printf("even\n");
- }
- else {
- printf("odd\n");
- }
- }
-
- }
- return 0;
- }