Q:

C Program To Print A Calendar By Taking Input From User Using Loop

0

Write A C Program To Print A Calendar By Taking Input From User Using Loop Like Taking a Start Date From User

 

Logic :

In this problem we are taking number of days and start date as input start day are given below .

Monday      -0
Tuesday      -1
Wednesday -2
Thursday    -3 
Friday         -4
Saturday     -5
Sunday       -6
 
Date Must Start With Given Days so we use a code 0 to 6 Monday to Sunday

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
    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 First Day Start From <0-Mon....5-Sat & 6-Sun> End With Sunday : ");
    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++;
    }
    getch();

}

 

Output:

C Program To Print a Calender  with Start with Input Day 

Enter Total Numbers Of Days in a Month :31

Enter First Day Start From <0-Mon . . . 5-Sat&6-Sun>End with Sunday :3

Mon           Tue           Wed         Thu          Fri              Sat            Sun

-----------------------------------------------------------------------------

                                                     1              2                3                4

5               6                   7              8              9               10              11

12             13                 14            15            16              17             18

19              20                 21           22             23              24             25

26              27                28           29             30              31  

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now