In this article I will show you the calendar app full project with source code by C++. You can make this code with any other language too giving the same logic.
You all know that C++ is a high level language by which we can make a calendar app full project very easily.
Let’s see the calendar app full project with source code by C++.
You may also like password strength checker full project by C++ and quiz game full project by C++ with source code.
Calendar app full project with source code
Let’s see source code bellow of calendar app full project using C++. Compile and run the code to get the result as given bellow;
// calendar app full project by C++
#include <iostream>
#include <iomanip>
#include <conio.h>
#include <time.h>
using namespace std;
void calendar_app(int year){
int t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
int month_days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; // Days in months
string list_of_month[] = {"January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"};
cout << " **************************************" << endl;
cout << " Welcome to " << year << endl;
cout << " **************************************" << endl << endl;
int i, days, current, y = year - 1;
current = (y + y/4 - y/100 + y/400 + t[0] + 1) % 7;
for(i = 0; i < 12; i++){
if(i == 1)
if(year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
days = 29;
else
days = month_days[i];
else
days = month_days[i];
cout << endl << " *************" << list_of_month[i] << "***************" << endl;
cout << " Sun Mon Tue Wed Thu Fri Sat" << endl;
int k;
for (k = 0; k < current; k++){
cout << " ";
}
for (int j = 1; j <= days; j++){
k++;
cout << setw(5) << j;
if (k > 6){
k = 0;
cout << endl;
}
}
if (k)
cout << endl;
current = k;
}
return;
}
int main(){
system("cls");
time_t ttime = time(0);
tm *local_time = localtime(&ttime); // get local time
int year = 1900 + local_time -> tm_year;
char option;
do{
system("cls");
calendar_app(year);
cout << endl << endl;
cout << "Want to see more? " << endl;
cout << " - press n for next year " << endl;
cout << " - press p for previous year " << endl;
cout << " - press e for exit " << endl;
option = getche();
switch(option){
case 'n':
year++;
break;
case 'p':
year--;
break;
}
}while(option != 'e' && option != 'E');
return 0;
}
Output of this calendar app full project with source code
After compiling and running of this calendar app full project with source code, you will see the calendar of current year. You can see calendar of other year too. Let’s see the output.
**************************************
Welcome to 2021
**************************************
*************January***************
Sun Mon Tue Wed Thu Fri Sat
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
*************February***************
Sun Mon Tue Wed Thu Fri Sat
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
*************March***************
Sun Mon Tue Wed Thu Fri Sat
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
*************April***************
Sun Mon Tue Wed Thu Fri Sat
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
*************May***************
Sun Mon Tue Wed Thu Fri Sat
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
*************June***************
Sun Mon Tue Wed Thu Fri Sat
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
*************July***************
Sun Mon Tue Wed Thu Fri Sat
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
*************August***************
Sun Mon Tue Wed Thu Fri Sat
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
*************September***************
Sun Mon Tue Wed Thu Fri Sat
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
*************October***************
Sun Mon Tue Wed Thu Fri Sat
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
*************November***************
Sun Mon Tue Wed Thu Fri Sat
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
*************December***************
Sun Mon Tue Wed Thu Fri Sat
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
Want to see more?
- press n for next year
- press p for previous year
- press e for exit
You can give more functionality as you want to get better result. Just press “n” for seeing the calendar of next year and “p” to see the calendar of previous year.
Hope you like this post. You can share your opinion and thoughts in the comment section bellow;