Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can I know why this code doesn't work? If the reason is because I pass today variable by reference, Can I know the reason why

Can I know why this code doesn't work? If the reason is because I pass "today" variable by reference, Can I know the reason why I can't pass the today variable by reference?

#include #include #include using namespace std; void sToD(Days & today,string day); enum Days { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, };

int main() { Days today; string day; cout << "what day is today"; cin >> day; sToD(today,day); cout << "Today is " << today << endl<

}

void sToD(Days & today,string day) { switch (toupper(day[0])) { case'S':if (toupper(day[1]) == 'A') today = SATURDAY; else today = SUNDAY; break; case 'M':today = MONDAY; break; case 'T':if (toupper(day[1]) == 'U') today = TUESDAY; else today = THURSDAY; break; case'W':today = WEDNESDAY; break; case'F':today = FRIDAY; break; default: cout << "****Invalid day input****"<

} }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions

Question

How do books become world of wonder?

Answered: 1 week ago

Question

If ( A^2 - A + I = 0 ), then inverse of matrix ( A ) is?

Answered: 1 week ago