Skip to content

Instantly share code, notes, and snippets.

@smukasa90
Created October 17, 2014 08:09
Show Gist options
  • Save smukasa90/20ff5d3cc1de86c6879e to your computer and use it in GitHub Desktop.
Save smukasa90/20ff5d3cc1de86c6879e to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main(){
int days, start, i, x, j = 0;
printf("please enter the number of days in the month: ");
scanf("%d", &days);
printf("\nplease enter the starting day (sun = 1 and sat = 7): ");
scanf("%d", &start);
printf("\n");
printf("su mo tu we th fr sa");
printf("\n");
for(x = 1; x < start; x++){
printf(" ");
j += 1;
}
for(i = 1; i <= days; i++){
j += 1;
if(i < 10){
printf(" %d ", i);
if((j%7) == 0){
printf("\n");
}
}
else{
printf("%d ", i);
if((j%7) == 0){
printf("\n");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment