Advertisement
mosaid

print month

Dec 3rd, 2020
1,000
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.77 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3.  
  4. void print_month(int start, int nb_days){
  5.     int i,j,a,n,m;
  6.     printf("  su  mo  tu  we  th  fr  sa  \n");
  7.     a=1;
  8.     for(i=0;i<=5;i++){
  9.         for(j=0;j<7;j++){
  10.             if(i==0 && j<start) printf("    ");
  11.             else{
  12.                 if(a<=nb_days) printf("%4d",a);
  13.                 a++;
  14.             }
  15.         }
  16.         printf("\n");
  17.     }
  18. }
  19.  
  20. int main(int argc, char *argv[]){
  21.     int nb_days = 31; // todo: make function returing nb_days knowing the month and the year
  22.     int starting_day = 4; // todo: think a litle harder to make a function that returns the starting day
  23.                         // it shouldn't be impossible , I've done it before
  24.     print_month(starting_day,nb_days);
  25.     return 0;
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement