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

Sort 740 Discussions, By:

recency

Please Login in order to post a comment

  • surbhimehta10111
    3 days ago+ 0 comments

    for( int i=a;i<=b;i++) { if(i<=9) { if(i==1) printf("one\n"); else if(i==2) printf("two\n"); else if(i==3) printf("three\n"); else if(i==4) printf("four\n"); else if(i==5) printf("five\n"); else if(i==6) printf("six\n"); else if(i==7) printf("seven\n"); else if(i==8) printf("eight\n"); else if(i==9) printf("nine\n"); } else { if(i%2==0) printf("even\n"); else printf("odd\n"); } }

    0|
    Permalink
  • tejabotcha525
    4 days ago+ 0 comments

    include

    include

    include

    include

    int main() { int a, b,i=0,j=0; scanf("%d\n%d", &a, &b); // Complete the code. for(i=0,j=0;i<=a,j<=b,i++,j++) { if(i==a) printf("one"); if(i==a) printf("two"); if(i==a) printf("three"); if(i==a) printf("four"); if(i==a) printf("five"); if(i==a) printf("six"); if(i==a) printf("seven"); if(i==a) printf("eight"); if(i==a) printf("nine"); if(i==b) printf("one"); if(i==b) printf("two"); if(i==b) printf("three"); if(i==b) printf("four"); if(i==b) printf("five"); if(i==b) printf("six"); if(i==b) printf("seven"); if(i==b) printf("eight"); if(i==b) printf("nine"); else { printf("nine"); } else if(a>9) printf("even"); else if(b>9) return 0; }

    0|
    Permalink
  • SagarShimpi2000
    5 days ago+ 0 comments

    for(i=a;i<=b;i++) { if(i==1) { printf("one\n"); } else if(i==2) { printf("two\n"); } else if(i==3) { printf("three\n"); } else if(i==4) { printf("four\n"); } else if(i==5) { printf("five\n"); } else if(i==6) { printf("six\n"); } else if(i==7) { printf("seven\n"); } else if(i==8) { printf("eight\n"); } else if(i==9) { printf("nine\n"); } else if(i>9 && i%2==0) { printf("even\n"); } else { printf("odd\n"); }

    }

    0|
    Permalink
  • devduttsahoo30
    5 days ago+ 0 comments

    char chr[9][6]={"one","two","three","four","five","six","seven","eight","nine"}; for(int i=a;i<=b;i++) { if(i<10){ printf("%s\n",chr[i-1]); } else{ if(i%2==0){ printf("even\n"); } else{ printf("odd\n"); } }

      }
    
    0|
    Permalink
  • gadilingappa1
    1 week ago+ 0 comments

    include

    include

    include

    include

    int main() { int a, b; scanf("%d\n%d", &a, &b); // Complete the code. int num; while(num!=0) { switch(num%10) { case 0:printf("zero"); break; 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("neon"); break; default:printf("not a valid"); } num/=10; } if (a%2==0)||(b%2==0) { printf("odd"); } else { { printf("even"); } }

    return 0;
    

    }

    0|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy