Homework4-3 - if (start == 1) printf(" "); else...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Homework #4 /* * Program HW4_3 * Written by Justin Waters * inputs: * Outputs: * Description: * * */ #include<stdio.h> //defines printf, scanf int main (void) { int days, start, i; //tells user what the program will do printf(" \nThis program will print out a one month calendar starting on\n the day you specify and using the number of days you want"); //gets number of days from user printf(" \nEnter the number of days in the month for your calendar > "); scanf("%d", &days); //gets the day of the week to start the calendar from the user printf(" \nChoose the day you need to start from\n"); printf(" \nEnter \n'0' for Sunday\n'1' for Monday\n'2' for Tuesday\n'3' for Wednesday\n'4' for Thursday\n'5' for Friday\n'6' for Saturday\n"); scanf("%d", &start); //prints the top part of the calander printf("\n S M T W T F S \n\n"); //determines spacing for the first day on the calendar
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: if (start == 1) printf(" "); else if (start == 2) printf(" "); else if (start == 3) printf(" "); else if (start == 4) printf(" "); else if (start == 5) printf(" "); else if (start == 6) printf(" "); else if (start == 0) printf(" "); //tells user he entered a wrong value and ends program else { printf(" You chose an incorrect value,sorry"); return (0); } //loop for starting new lines as the days are printed for(i=1;i<=days;++i){ if (i == (8 - start)) printf("\n\n "); else if (i == ((8 - start) + 7)) printf("\n\n "); else if (i == ((8 - start) + 14)) printf("\n\n "); else if (i == ((8 - start) + 21)) printf("\n\n "); else if (i == ((8 - start) + 28)) printf("\n\n "); else ; //changes spacing for 2 numbered values for neatness if(i>9) printf(" \b%d ", i); else printf("%d ", i); } return (0); }...
View Full Document

This note was uploaded on 08/06/2008 for the course EGR 261 taught by Professor Parikh during the Spring '08 term at Grand Valley State University.

Page1 / 2

Homework4-3 - if (start == 1) printf(" "); else...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online