Giter Site home page Giter Site logo

calendar-using-c's Introduction

Important

THIS CODES ARE DEVELOPED BYLORENCE ISIDORO

Tip

THIS C++ CODE HAVE A SAME CODE EXAMPLE : they have the same code, they use Zeller's Congruence Algorithm, the only difference is in the if, else statement, just added a switch statement which is the months.

CALENDAR USING C++

Zeller's Congruence Algorithm

if, else statement

Basic C++ Project

Click here to view the Calendar if, else statement.docs

int DAYSINMONTH(int month, int year) {
  if (month == 4 || month == 6 || month == 9 || month == 11) {
    return 30;
  } else if (month == 2) {
    return ISLEAPYEAR(year) ? 29 : 28;
  } else {
    return 31;
  }
}

int DAYSOFYEAR(int year, int month, int day) {

  int DAYSINMONTH[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
  year -= month < 3;
  return (year + year / 4 - year / 100 + year / 400 + DAYSINMONTH[month - 1] + day) % 7;
}

Screenshot 2024-05-05 153337

CALENDAR USING C++

Zeller's Congruence Algorithm

if, else with Switch statement

Basic C++ Project

Click here to view the Calendar if, else with switch statement.docs

int DAYSINMONTH(int month, int year) {
  switch (month) {
    case 1:
        case 3:
            case 5:
                case 7:
                    case 8:
                        case 10:
                            case 12:
      return 31;
    case 4:
        case 6:
            case 9:
                case 11:
      return 30;
    case 2:
      return ISLEAPYEAR(year) ? 29 : 28;
    default:
      return 0;
  }
}


int DAYSOFYEAR(int year, int month, int day) {

  int DAYSINMONTH[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
  year -= month < 3;
  return (year + year / 4 - year / 100 + year / 400 + DAYSINMONTH[month - 1] + day) % 7;

Screenshot 2024-05-05 161138

calendar-using-c's People

Contributors

ctorw 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.