We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- C
- Conditionals and Loops
- For Loop in C
- Discussions
For Loop in C
For Loop in C
Sort by
recency
|
831 Discussions
|
Please Login in order to post a comment
int main() { int a, b; int i; scanf("%d\n%d", &a, &b); // Complete the code. for(i=a;i<=b;i++){ if(i>=1&&i<=9){ switch (i) { case 1: printf("one\n"); break; case 2: printf("two\n"); break; case 3: printf("three\n"); break; case 4: printf("four\n"); break; case 5: printf("five\n"); break; case 6: printf("six\n"); break; case 7: printf("seven\n"); break; case 8: printf("eight\n"); break; case 9: printf("nine\n"); break; } } else if(i%2==0){ printf("even\n");
} else{ printf("odd\n"); } } return 0; }
Printing the condition using for loop
Here I declared
word()
function for print the numbers in word.int main() { int a, b; char arr[9][9] = {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
}
include
include
include
include
void string(int a , int b, int n) { int i; for(i=a;i<=b;i++) { if(i>=1 && i<=9) { if(i==1) { printf("one"); } if(i==2) { printf("two"); } if(i==3) { printf("three"); } if(i==4) { printf("four"); } if(i==5) { printf("five"); } if(i==6) { printf("six"); } if(i==7) { printf("seven\n"); } if(i==8) { printf("eight\n"); } if(i==9) { printf("nine\n"); }
}
int main() { int a, b,n=6; scanf("%d\n%d", &a, &b); string(a,b,n);
}
void check_digit(int x) { if ((x >= 1) && (x <= 9)) { if (x == 1) { puts("one"); } else if (x == 2) { puts("two"); } else if (x == 3) { puts("three"); } else if (x == 4) { puts("four"); } else if (x == 5) { puts("five"); } else if (x == 6) { puts("six"); } else if (x == 7) { puts("seven"); } else if (x == 8) { puts("eight"); } else if (x == 9) { puts("nine"); } } if (x > 9) {
if ((x % 2) == 0) { puts("even"); } else { puts("odd"); } } }
int main() { int a, b; scanf("%d\n%d", &a, &b);
}