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. Introduction
  4. For Loop
  5. Discussions

For Loop

Problem
Submissions
Leaderboard
Discussions
Editorial

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

  • vedikadwivedi241
    2 months ago+ 0 comments

    include

    include

    using namespace std;

    int main() { // Complete the code. int a,b; cin >>a; cin >>b;

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

    }

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