06/02/2023

C Program to Print The Calendar of a Month of 31 Days

write a program to print the calendar of a month of 31 days. the program must take a day of the week as input. this will be the day on which the 1 day of the month will start. the program must print the rest of the month based on the input. In this problem, we are taking a number of days and start date as input start day is given below.

Enter 0 for Monday:
Enter 1 for Tuesday:
Enter 2 for Wednesday:
Enter 3 for Thursday:
Enter 4 for Friday:
Enter 5 for Saturday:
Enter 6 for Sunday:

One Month Calendar Program in C Programming Language.

C Program to Print The Calendar of a Month

Check: C Program to Count the Number of Digits of A Number

C Program to Print The Calendar of a Month


#include<stdio.h>

void main() {
  /* C Program to Print Calendar of a Month
   */
  int i, j, k, day, dt = 1;

  printf("C Program to Print a Calendar With Start With Input Day\n\n");

  printf("Enter Total Numbers of Days in a Month:");
  scanf("%d", & day);

  printf("\n\nEnter 0 for Monday:");
  printf("\nEnter 1 for Tuesday:");
  printf("\nEnter 2 for Wednesday:");
  printf("\nEnter 3 for Thursday:");
  printf("\nEnter 4 for Friday:");
  printf("\nEnter 5 for Saturday:");
  printf("\nEnter 6 for Sunday:");
  printf("\n\nChoose Between 0 to 5:");
  scanf("%d", & k);

  printf("\nMon \tTue \tWed \tThu \tFri \tSat \tSun \n\n");
  printf(" _________________________________________________\n\n");

  for (j = k; j > 0; j--) {
    printf("\t");
  }

  while (dt <= day) {
    if (k != 0) {
      if (k % 7 == 0)
        printf("\n");
    }

    printf("%d\t", dt);
    dt++;
    k++;
  }
}

The Output of Calendar Program in C


The Output of Calendar Program in C
Previous Post
Next Post

post written by:

Hi, I’m Ghanendra Yadav, SEO Expert, Professional Blogger, Programmer, and UI Developer. Get a Solution of More Than 500+ Programming Problems, and Practice All Programs in C, C++, and Java Languages. Get a Competitive Website Solution also Ie. Hackerrank Solutions and Geeksforgeeks Solutions. If You Are Interested to Learn a C Programming Language and You Don't Have Experience in Any Programming, You Should Start with a C Programming Language, Read: List of Format Specifiers in C.
Follow Me

0 Comments: