Enquiries for if-else statement structure | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Enquiries for if-else statement structure

I want to design an choice program for user. I have designed something like this, there is no last "else" because ans D is to exit the loop without printing anything. do { If ( ans == A) {} else if ( ans == B) {} else if (ans == C) {} } while ( ans != D); Is my design very weird ? Or there is any suggestion in terms of design. (please take note option D is just exit)

15th Apr 2022, 8:11 AM
Jacky
2 Answers
15th Apr 2022, 8:20 AM
Simba
Simba - avatar
0
Use switch cases..
15th Apr 2022, 8:22 AM
Jayakrishna 🇮🇳