0

Is this code good enough for beginners like me?

https://code.sololearn.com/cgrJiAmhAKVw/?ref=app

18th Dec 2019, 4:02 AM
Amey Pathe
Amey Pathe - avatar
4 Answers
+ 1
although you usually wouldn't use switch cases for this, I guess it serves well enough as an exercise for a beginner. one suggestion though: put a printf ("\nToday is "); right before your switch statement, so you have less typing to do within each case. this is part of the DRY principle (don't repeat yourself), which always leads to better code when followed. other than that, keep up the good work and never stop learning!
18th Dec 2019, 5:18 AM
grdr
0
I just learned switch that's way I tried to make with switch
18th Dec 2019, 11:20 AM
Amey Pathe
Amey Pathe - avatar
0
Amey Pathe of course, like I said it's good as an exercise for learning switches.
19th Dec 2019, 3:23 AM
grdr
0
Coder Kitten the ways you can solve this depend on the language used of course. the most simple approach that works in most languages, including C, would be an array containing all 7 names. I wrote a quick example to illustrate what I mean. This can still be used in a switch structure but I used the (in my opinion) more elegant approach. here you go: https://code.sololearn.com/cttHAGl0evBX/?ref=app
19th Dec 2019, 3:25 AM
grdr