Help with codes | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Help with codes

I try to make a program that calculates a given date whether that day is a Sunday, Monday or other day. putting the program lines here asks too much from this message post. I rather point to my codes and watch it there. My question: is there a way to make this better, other than over use the'if' function?

31st Jan 2018, 9:06 AM
HOGELING TEKENtechniek
HOGELING TEKENtechniek - avatar
2 Answers
+ 4
its definitely possible.
31st Jan 2018, 9:25 AM
shobhit
shobhit - avatar
+ 1
switch-case maybe or string array[7] from monday do sunday and modulo (%), like: February 3, sum= 31(january)+3=34, day=sum%7, cout << array[day]. 34%7 is 6 so array[6] is sunday
31st Jan 2018, 10:19 AM
rafal