Sort by

recency

|

831 Discussions

|

  • + 0 comments

    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; }

  • + 0 comments

    Printing the condition using for loop

    Here I declared word() function for print the numbers in word.

    #include<stdio.h>
    void word(int x){
        switch(x){
            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;
            default:
                break;
        }
    }
    int main(){
        int a, b, x;
        scanf("%d\n%d", &a, &b);
        //for loop starts..
        for(int i = a; i<=b ; i++){
            if(i > 0 || i<=9){
                word(i);
            }else
                break;
        }
        for(int i = a; i<=b; i++){
            if(i>9){
                int j = (i%2);
                if(j == 0){
                    printf("even\n");
                }else if(j == 1){
                    printf("odd\n");
                }
                else
                    break;
    
            }
        }
    }
    
  • + 0 comments

    int main() { int a, b; char arr[9][9] = {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};

    scanf("%d\n%d", &a, &b);
    
    for (int i = a; i < b+1; i++){
        if ( 1 <= i && i <= 9){
            printf("%s\n", arr[i - 1]);
    
        } else if (i > 9){
            if (i % 2 == 0){
                printf("even\n");
            } else{
                printf("odd\n");
            }
        } 
    }
    
    return 0;
    

    }

  • + 0 comments

    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"); }

    }
    
    
    else if(i > 9)
    {
    
        if(i%2 == 0)
        {
            printf("even\n");
        }
        else
        {
         printf("odd\n");
        }
    }
    else
    {
        printf("Invalid Operation\n");
    
    }
    
    }
    

    }

    int main() { int a, b,n=6; scanf("%d\n%d", &a, &b); string(a,b,n);

    return 0;
    

    }

  • + 0 comments

    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);

    for (int i = a; i <= b; i++) {
        check_digit(i);
    }
    return 0;
    

    }