Guys, you are looking at this in a way too complicated fashion!

How's about this algorithm:

Get month name, days in Month, and start day.
Print the weekday headers (Sunday to Saturday)...