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.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. C
  3. Conditionals and Loops
  4. For Loop in C
  5. Discussions

For Loop in C

Problem
Submissions
Leaderboard
Discussions
Editorial

    You are viewing a single comment's thread. Return to all comments →

  • yssnabbou2002
    3 months ago+ 0 comments

    include

    include

    int main() { int a,b,i; char tab[][9]={"one","two","three","four","five","six","seven","eight","nine"}; do{ printf("Enter an integer a :"); scanf("%d",&a); printf("Enter an integer b :"); scanf("%d",&b); }while(a>b);

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

    }

    0|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy