Sort by

recency

|

841 Discussions

|

  • + 0 comments

    include

    include

    include

    include

    int main() { int a, b; scanf("%d\n%d", &a, &b); // Complete the code. char *nums[9] = {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine"}; for(int i = a; i <= b; i++){ if(i > 0 && i < 10) printf("%s\n", nums[i-1]); else{ if(i % 2 == 0) printf("even\n"); else printf("odd\n"); }
    }
    return 0; }

  • + 0 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
    
  • + 0 comments

    This challenge is a great way to practice using the for loop and conditional statements effectively. 11xplay Pro Login

  • + 0 comments
    int main() 
    {
        int a, b;
        scanf("%d\n%d", &a, &b);
      	// Complete the code.
        char *numbers[] = {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
        for (int i = a; i <= b; i++) {
            if (i <= 9)
                printf("%s\n", numbers[i-1]);   
            else if (i > 9) {
                char *even_or_odd = (i % 2 == 0) ? "even" : "odd";
                printf("%s\n", even_or_odd);   
            }
        }
    }
    
  • + 0 comments

    include

    void digitnames(int n){ char *digitNames[] = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};

    if (n >= 0 && n <= 9)
    {
        printf("%s\n", digitNames[n]);
    
    }
    if (n>=10){
        printf("nine\n");
    }
    

    } void oddeven(int m){ int odd,even; if(m%2==0){ printf("even\n"); }else{printf("odd\n");} } int main() { int digitstore[2]; for (int i = 0; i < 2; i++) { scanf("%d", &digitstore[i]); }

    for (int i = 0; i < 2; i++) {
        digitnames(digitstore[i]);
    }
    
    for (int i = 0; i < 2; i++) {
    

    * oddeven(digitstore[i]); }

    return 0;
    

    }