Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Green University of Bangladesh

Department of Computer Science and Engineering(CSE)


Faculty of Sciences and Engineering
Semester: (Summer, Year:2021), B.Sc. in CSE (Day)

Course Title : Structured Programming Lab


Course Code : CSE 104
Section : 211DC
Project Title : Making Calendar Using C program.

Student Details:
Name ID

MD. EMON 211002117

Submission Date : 7/9/2021


Course Teacher’s Name : Humayan Kabir Rana
Introduction:
In this project I am going to make a Calendar using C Program. Calendars play an
important role in our day to day life. They help us plan our routine, celebrate
special days, remember important dates and organize major events. Life
would not have been the same if it weren't for these systems.

Program Interface:

1.Start
2.Take a character type string array enter month names. And also take array
called ‘daysinmonth’ and enter total days in each month.
3. Read a favorite year you want to see in calendar.
4.Now taking a for loop to print month and week days name. And take a
nested for loop to enter space before new month. And a nested for loop to
print each date of month.in nested loop use a ‘if’ condition to line break when
week days is 7.
5.Taking a ‘if’ condition before all loop to solve leap year problem.so that we
can get exactly same days if it’s also a leap year.
6.Now taking a function before main function to return first day of a year.
Using ‘firstdayoftheyear’ this function. And return this value before entering
the loop.
Program Execution:

#include<stdio.h>

int firstdayoftheyear(int year){


int day = (year*365 +((year-1)/4) - ((year-1)/100) + ((year-1)/400)) % 7;
return day;
}

int main(){
char *months[]={"January","February","March","April"," May "," Jun "," July
","August","September","October","November","December"};
int daysinmonths[]={31,28,31,30,31,30,31,31,30,31,30,31};

int i,j,totaldays,weekday=0,spacecounter=0,year;

printf("Enter you Favourite year:");


scanf("%d",&year);
printf("\n\n***************Welcome to %d********************\n\n",year);

if(( year % 4 == 0 && year % 100 != 0 ) || ( year % 400 == 0 )){


daysinmonths[1]=29;
}
weekday = firstdayoftheyear(year);
for(i=0;i<12;i++){
printf("\n\n\n--------------------- %s ----------------------\n",months[i]);
printf("\n Sun Mon Tue Wed Thu Fri Sat\n\n");

for(spacecounter=1;spacecounter<=weekday;spacecounter++){
printf(" ");
}

totaldays=daysinmonths[i];
for(j=1;j<=totaldays;j++){
printf("%6d",j);
weekday++;

if(weekday > 6){


weekday = 0;
printf("\n");
}
}
}

return 0;

}
Input and Output:
Program Structure:

“*months[]” by this we initialized Month name.


“daysinmonths[]” by this we initialized how many day have in a month.
We also use some variable like as totaldays,weekday,spacecounter.

In this project we use only one function witch name is ‘ firstdayoftheyear ‘


By using this we got the first day and initialized it before starting the loop in
weekdays.
Before starting the loop we also did little word by using if condition we got
the leap year month dates using those condition.
And then by using loop we print the name of month name of weeks and also
all dates of a month. And we use more than 1 nested loop to do those works.
We also use a loop for make line spacing accurate. In those nested loop we
also use a condition to break line when dates is 7.
Scope of Improvement:
My project have many more area to improve, but specially we need to
improve design part we can add more design and graphics. And also, we
can make runtime faster and I think it’s a less flexible program so if there any
scope so we can make it more flexible. But in my opinion I think we can add
more design. which I think maybe not possible because we use c program
to do our project and we all know that “C” doesn’t have more fetchers to add
design and graphics etc. In my opinion those are the area to improve.

Difficulties Encountered:
It is a new language of me so. It took while to understand but now I am quite
comfortable than before. By doing this project I face few difficulties using
strings/functions because I learn then recently. But by practicing regular now
I have clear concept about it.in this project I use loop and array more than
others topic. I face few problems but now I overcome It and I successfully
did my project. Calendar is one of the most useful things in our regular life
that is the main reason, why I chose this topic for my lab project.
Conclusions:
As we all know calendar is use for counts days. By using C program, we can
make a calendar quite easily. Even I also did this quite easily and the reason
I chose this topic because personally I use calendar more and when I was
thinking about project topic then first thing that come into my mind is calendar
and eventually, I did few research and then I chose the easiest and most
uncomplicated way to create a calendar which you already maybe noticed in
my project. I may face few difficulties but somehow, I finally did this quite
comfortably. And finally, when it works properly it was a great feeling.

References:

Calendar system- https://g.co/kgs/5bxmM3


Calendar- https://en.wikipedia.org/wiki/Calendar
C Programing - https://g.co/kgs/iK4ubD
Projects by CodeBlocks- https://www.dummies.com/programming

You might also like