MCPcopy Create free account
hub / github.com/Apress/beginning-cpp20 / ending

Function ending

Exercises/Modules/Chapter 08/Soln8_01.cpp:83–93  ·  view source on GitHub ↗

Select the ending of the ordinal day number

Source from the content-addressed store, hash-verified

81
82// Select the ending of the ordinal day number
83std::string ending(int date_day)
84{
85 if (date_day == 1 || date_day == 21 || date_day == 31)
86 return "st";
87 else if (date_day == 2 || date_day == 22)
88 return "nd";
89 else if (date_day == 3 || date_day == 23)
90 return "rd";
91 else
92 return "th";
93}

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected