GithubHelp home page GithubHelp logo

calendar-generation-in-c's Introduction

Note : Program Starts from main function (int main()) Algorithim of the code goes as:

Step-1 We take the year(century) from user as int value and store it in 'year'

Step-2 We take the month (as jan ,feb...) as string and store it in 'month'

Step-3 we form an array (arr) of months as(char *arr[]={"jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"}

step-4 Then we compare month entered by the user with all the elements of above array using for loop and if the entered month matches then we assign the value of varailble 'n' the index of entered month in array (for eg : for jan . n=0, feb, n=1 and so on..for dec n=11)

step-5 Now switch cases are formed for all the months with 'n' as argument of switch (switch(n)) hence if user entered "mar" (March ) then n=2(from above step we got the value of n ) and we will be forwarded to case(2) and all the instructions under case(2) will be executed .

Step-6 in each case first we call a function first_day which will return first day of the entered month in the from of integer from 0-6 such that 0 represents Sunday , 1-monday and so on till 6- Saturday . Hence if the function returns 1 the first day of the month is Monday. This returned int value is stored in int variable 'Ist_day'. Note: zellar's rule has been used to find first day of the month. (https://www.careeranna.com/articles/find-day-for-given-date-quickly/)

Step -7 Now we know the day(Sun-Sat) from which our calendar will start so all we need to do now is print the dates starting from the first day and then print all the dates till the last day of the entered month (i.e 30 or 31 or 29 or 28) So for printing the calendar we call a function display_calendar and pass the name of month, first day of month and no. of days in entered month

calendar-generation-in-c's People

Contributors

aman-tiwari-05 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.