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. Conditional Statements
  5. Discussions

Conditional Statements

Problem
Submissions
Leaderboard
Discussions
Editorial

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

  • gonestill
    2 months ago+ 0 comments
    void printString(int n){
        std::vector<std::string> stringsVector 
        = {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
        std::string outString = "Greater than 9";
        
        if (n <= 9){
            outString = stringsVector[n-1];
        }
        
        std::cout<<outString<<std::endl;
        
        return;
    }
    
    1|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy