Hey fox... got a problem in codding im a newbie at this so take it easy on me ...
The question
Write a C++ program by completing the following steps:
Write a value-returning string function called MonthAbbrev that takes an int value as a parameter. The parameter, month, represents the number of the month. The function returns a string containing the three-letter abbreviation for the corresponding month number. Assume that the month number is in the range of 1 to 12.
Modify the function in Step 1 to handle month numbers that are not in the valid range by returning the string “Inv”.
Write the main function that reads an integer number from keyboard, call the function using the read in number as argument, and display the three-letter abbreviation returned by the function.
what i have done so far
#include<iostream>
using namespace std;
int k;
string MonthAbbrev
{
string mon[] = {"JAN" ,"FEB", "MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"};
if(k>0 && k<13)
return mon[k-1];
return "Inv";
}
int main()
{
int a;
cout <<" enter month number u want ";
cin >>a ;
cout << MonthAbbrev(a)<< endl;
return 0;
}