code.cpp 713 B

12345678910111213141516171819202122
  1. /* Create a function that takes a number (from 1 to 12) and returns
  2. * its corresponding month name as a string. For example,
  3. * if you're given 3 as input, your function should return "March",
  4. * because March is the 3rd month.
  5. */
  6. std::string monthName(int num) {
  7. switch (num){
  8. case 1 : return "January"; break;
  9. case 2 : return "February"; break;
  10. case 3 : return "March"; break;
  11. case 4 : return "April"; break;
  12. case 5 : return "May"; break;
  13. case 6 : return "June"; break;
  14. case 7 : return "July"; break;
  15. case 8 : return "August"; break;
  16. case 9 : return "September"; break;
  17. case 10 : return "October"; break;
  18. case 11 : return "November"; break;
  19. case 12 : return "December"; break;
  20. }
  21. return 0;
  22. }