Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>;
- using namespace std;
- int main()
- {
- // Declaring Input Variables
- int day; int month; int year;
- // Asking the user for input
- cout << "Please insert date (DD MM YY)\n";
- cin >> day >> month >> year;
- cout << endl;
- // Adding day modifier
- if (day == 01 || day == 21 || day == 31)
- {
- cout << day << "st ";
- }
- else if (day == 02 || day == 22)
- {
- cout << day << "nd ";
- }
- else if (day == 03 || day == 23)
- {
- cout << day << "rd ";
- }
- else if (day > 31)
- cout << "DAY ERROR ";
- else
- {
- cout << day << "th ";
- }
- // Converting the month to text
- switch (month)
- {
- case 1: cout << "January "; break;
- case 2: cout << "Febuary "; break;
- case 3: cout << "March "; break;
- case 4: cout << "April "; break;
- case 5: cout << "May "; break;
- case 6: cout << "June "; break;
- case 7: cout << "July "; break;
- case 8: cout << "August "; break;
- case 9: cout << "September "; break;
- case 10: cout << "October "; break;
- case 11: cout << "November "; break;
- case 12: cout << "December "; break;
- default: cout << "MONTH ERROR "; break;
- }
- // Print the year at the end
- cout << year << endl << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement