All Projects

Bus Ticket Booking System in Python
Bus Ticket Booking System in Java
Bus Ticket Booking System in Cpp
Bus Ticket Booking System in C
Cafe Order System in Python
Cafe Order System in Java
Cafe Order System in Cpp
Cafe Order System in C
Social Media Account Details Manager in Python
Social Media Account Details Manager in Java
Social Media Account Details Manager in Cpp
Social Media Account Details Manager in C
Mini ATM in Python Language
Mini ATM in Java Language
Mini ATM in cpp language
Mini ATM in c language
Pocket Money Manager in Python Language
Pocket Money Manager in Java Language
Pocket Money Manager in Cpp Language
Pocket Money Manager in C Language
Username Password Generator in Python Language
Username Password Generator in Cpp Language
Username Password Generator in C Language
Telephone Directory in Python Language
Telephone Directory in Java Language
Telephone Directory in Cpp Language
Telephone Directory in C Language
Calander in Cpp Language
Calander in C Language
NoteBook in Python Language
NoteBook in Cpp Language
NoteBook in C Language
Voting System in Python Language
Voting System in Java Language
Voting System in Cpp Language
Voting System in C Language
Age Calculator in Python Language
Age Calculator in Java Language
Age Calculator in Cpp Language
Age Calculator in C Language
Currency Converter in Python Language
Currency Converter in Java Language
Currency Converter in Cpp Language
Currency Converter in C Language
Random Password Generator in python language
Random Password Generator in java language
Random Password Generator in cpp language
Random Password Generator in c language
Billing System in python language
Billing System in c++ language
Billing System in c language
Atm in c language

Calander in Cpp Language


Aniket The Programmer

1.22K+ Subscribers

Click To Subscribe My Channel

Subscribe

Source Code

        
#include <iostream>
#include<time.h>
using namespace std;

bool isLeapYear(int year) {
    return ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0));
}

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

int main() {
    int year, month;
    
    cout << "Enter year: ";
    cin >> year;
    cout << "Enter month (1-12): ";
    cin >> month;
    
    int days = daysInMonth(year, month);
    
    cout << "\n==============================\n";
    cout << "       " << year << "-" << (month < 10 ? "0" : "") << month << endl;
    cout << "==============================\n";
    cout << " Sun Mon Tue Wed Thu Fri Sat\n";
    
    tm time_in = {};
    time_in.tm_year = year - 1900;
    time_in.tm_mon = month - 1;
    time_in.tm_mday = 1;
    mktime(&time_in);
    int startingDay = time_in.tm_wday;
    
    for (int i = 0; i < startingDay; ++i) {
        cout << "    ";
    }
    
    for (int day = 1; day <= days; ++day) {
        cout << (day < 10 ? "  " : " ") << day << " ";
        if ((day + startingDay) % 7 == 0 || day == days) {
            cout << endl;
        }
    }
    
    cout << endl;
    return 0;
}
        
    

Source Code Github Link: View

View Video On Youtube Link: View

35k+ Coding Problems: Edocgram is collection of 35k+ coding problems Edocgram! 🎉