Sort by

recency

|

861 Discussions

|

  • + 0 comments

    For C

    I wrote the code from scratch just to get more practice

    #include<stdio.h>
    
    int main()
    {
        int a, b;
        scanf("%d\n%d", &a, &b);
        
        for(int i=a; i<=b; i++)
        {
            if(i >= 1 && i <= 9)
            {
                switch(i)
                {
                    case 1:
                        printf("%s\n", "one");
                        break;
                    case 2:
                        printf("%s\n", "two");
                        break;
                    case 3:
                        printf("%s\n", "three");
                        break;
                    case 4:
                        printf("%s\n", "four");
                        break;
                    case 5:
                        printf("%s\n", "five");
                        break;
                    case 6:
                        printf("%s\n", "six");
                        break;
                    case 7:
                        printf("%s\n", "seven");
                        break;
                    case 8:
                        printf("%s\n", "eight");
                        break;
                    case 9:
                        printf("%s\n", "nine");
                        break;
                }
            }
            else
            {
                if(i % 2 == 0)
                    printf("%s\n", "even");
                else
                    printf("%s\n", "odd");
            }
        }
        
        return 0;
    }
    
  • + 1 comment

    That simple version and u dont need to handling every case. If u have any qs I'am Here.

    #include <stdio.h>
    int main(void)
    {
        int a, b;
        scanf("%d\n%d", &a ,&b);
        const char *nbword[10] = {"zero", "one", "two", "three", "four" ,"five", "six", "seven" ,"eight", "nine"};
        
        int i = a;
        while (i <= b)
        {
            if (i >= 1 && i <= 9)
                printf("%s\n", nbword[i]);
            else 
            {
                if (!(i % 2 == 0))
                    printf("odd\n");
                else
                    printf("even\n");
            }
            i++;
        }
    

    }

  • + 0 comments
    /*  I am sharing my solution to this challenge. Any comments are welcome, as they help me improve. Thank you. */
    
    #include <stdio.h>
    
    int main() {
        int a, b;
        scanf("%d\n%d", &a, &b);
        
        for (short i = a; i <= b; i++) {
            
            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;
                default:
                    if (i % 2 == 0) {
                        printf("even\n");
                    } else {
                        printf("odd\n");
                    }
                    break;
            }
        }
    
        return 0;
    }
    
  • + 0 comments

    Penetration testing is one of the most effective ways to uncover hidden security risks before attackers do. A must-have for any serious cybersecurity strategy.

  • + 0 comments

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

    }
    return 0;
    

    }