Ask your own question, for FREE!
Computer Science 15 Online
OpenStudy (anonymous):

Kindly assist me with making a single loop out of these four 'if' statement blocks. They're in the 'void room(room *room)' function. Here's the link to the code: http://txt.do/dbyw Thank you!

OpenStudy (rsmith6559):

A simple change would be to go to if/ else if / else statement, but the switch statement is used for n-way branches.

OpenStudy (anonymous):

I'm sorry, I don't understand. How does the if/else help with making it a single loop? Why did you mention the switch statement concept? n-way branching: number of switch statements involve? Do you have anything in particular I could read? Thanks.

OpenStudy (anonymous):

My C is super rusty, but I think something like this should work: char *directions[4] = ["North \t", "South \t", "West \t", "East \t"]; for (i = 0; i < 4; i++) { if(room->neighbors[i] != NULL) { cout << directions[i]; } } or something to that extent...

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!