labprog5-2010 - 16 17 18 19 20 21 22 23 24 25 26 27 28 29...

Info icon This preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Swinburne University of Technology Faculty of Engineering and Industrial Sciences HES1300 Laboratory worksheet 5: To practice the use of control structure commands in C, students are asked to write a simple C program to print a calendar month. The program should ask the user to enter 2 integer numbers. The first is the number of days in the month and the second is the start day of the month (Sunday is 0, Monday 1, …Saturday 6). A typical result would look like: Sun Mon Tue Wed Thu Fri Sat --- --- --- --- --- --- --- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 --- --- --- --- --- --- --- A partial implementation of this program may look like: #include<stdio.h> int main() { int days, startDay, dayCount, weekDay; … printf("Sun Mon Tue Wed Thu Fri Sat\n"); … for(dayCount = 1; dayCount <= days; dayCount ++) { if(weekDay > 6) { printf("\n"); weekDay = 1; } else { weekDay ++; } printf("%3d ",dayCount); } printf("--- --- --- --- --- --- ---\n"); return(0); } After finishing the first part, try to rewrite your code using “while” and/or “do-while” commands....
View Full Document

  • Three '10
  • lauren
  • Week-day names, Monday, Thai solar calendar, #include, Swinburne University of Technology, Faculty of Engineering and Industrial Sciences

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern