Something like this:
const std::string SINGLE = "Single" ;
const std::string MARRIED = "Married" ;
const std::string INVALID = "??????" ;
if( marital_status == 1 ) std::cout << SINGLE ;
else if( marital_status == 2 ) std::cout << MARRIED ;
else cout << INVALID ;
Alternatively, use a switch-case.
You need to: #include <string> and also perhaps validate user input.
vijayan121
Posting Virtuoso
1,606 posts since Dec 2006
Reputation Points: 1,159
Solved Threads: 287