0
Is this code good enough for beginners like me?
4 Réponses
+ 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!
0
I just learned switch that's way I tried to make with switch
0
Amey Pathe of course, like I said it's good as an exercise for learning switches.
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