0% found this document useful (0 votes)
53 views11 pages

C Pro

This document summarizes a C program for dynamic calendar generation. The program uses functions like printCalendar() and printYearCalendar() along with arrays to store month names and day abbreviations. It allows users to view calendars for a specific month or entire year through a menu. The program implements validation checks and handles errors gracefully to provide an interactive calendar generation experience.

Uploaded by

Kayam Saikrishna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views11 pages

C Pro

This document summarizes a C program for dynamic calendar generation. The program uses functions like printCalendar() and printYearCalendar() along with arrays to store month names and day abbreviations. It allows users to view calendars for a specific month or entire year through a menu. The program implements validation checks and handles errors gracefully to provide an interactive calendar generation experience.

Uploaded by

Kayam Saikrishna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Department of Artificial Intelligence and Machine Learning

Mini Project Phase- I


“C Project on Calendar”

Under the Supervision


Prof. A Manusha Reddy
Dept. of CSE, SOET

Presented By:
KAYAM SAI KRISHNA (22BBTCA077)
HARSHITH G H (22BBTCA061)
YASWANTH RAJU KONDURU (22BBTCA081)
DEVENDHAR YADAV (22BBTCA076)
OVERVIEW

Introduction

Program Structure

Arrays for Month Names and Day Abbreviations

Calculating Days in a Month

Printing Calendar Components

User Interaction and Menu-Driven Programs
Dynamic Calendar Generation in C

INTRODUCTION


Purpose: Develops a C program for dynamic calendar generation.

Functionality: Displays calendars for specific years and months.

Overview: Unveiling the inner workings of the C program.

Key Components: Understanding the code structure and logic.

User Interaction: Interactive and user-friendly calendar generation.

Focus: Exploration of the code behind dynamic calendar creation in C.
Program Structure
FUNCTIONS

print Calendar Function :

Responsible for printing the calendar for a specific year and month.

Determines the number of days in the month based on conditions.

Calculates the day of the week for the first day of the month.

print Year Calendar Function :

Displays calendars for all months in a given year.

Calls the ‘printCalendar’ function for each month.

Main Function :

Implements a menu-driven program for user interaction.

Allows users to view the entire year’s calendar or a specific month.

Calls the appropriate functions based on user input.

Arrays :

Uses arrays to store month names (‘months[ ]’) and day abbreviations (‘days[ ]’).

Conditional Statements :

Utilizes conditional statements to determine the number of days in a month.

Includes special conditions for February and leap years.
Flow Chart
START

Display Menu

User Input

(Yes) Year/ (No)


Month
View

Call printCalendar

Display Calendar

End
Arrays for Month Names and Day Abbreviations


months[ ] :

Usage: Represents an array storing month names.

Implementation: Accessed based on the index to retrieve the corresponding
month name.

Example: months[0] for January, months[1] for February, and so on.


days[ ] :

Usage: Represents an array storing day abbreviations.

Implementation: Accessed based on the index to retrieve the corresponding
day abbreviation.

Example: days[0] for Sunday, days[1] for Monday, and so on.
Calculating Days in a Month


Logic for Handling Different Months and Leap Years:

1. Conditional Statements:

• Utilized to determine the number of days in a month.


• Example: Check if the month has 30, 31, or 28/29 days.

2. Handling February:

• Special conditions for February due to its varying number of days.


• Checks for leap years using conditional statements.

3. Leap Year Conditions:

• Checks if the year is a leap year.


• Leap years have 29 days in February; non-leap years have 28.
Printing Calendar Components

Header :

• Representation: Displayed at the top of each calendar.


• Content: Includes the month and year.
• Implementation: Printed using a formatted header statement.


Days of the Week:

• Representation: Displayed above the calendar grid.


• Content: Abbreviations for each day (Sun, Mon, Tue, ..., Sat).
• Implementation: Printed using a loop and array access.

Calendar Grid:

• Representation: Displayed in a grid format.


• Content: Shows the days of the month.
• Implementation: Utilizes loops to populate the grid, considering the
day of the week and the number of days in the
month.
User Interaction and Menu-Driven Program


main() Function:

• Role: Serves as the entry point for the program.


• Functionality: Implements a menu-driven approach for user interaction.
• Implementation: Contains a loop to repeatedly display the menu and handle user
choices.

User Input Handling:

• scanf() Function: Used to capture user input.


• Menu Choices: Allows users to choose options such as viewing the entire year's
calendar or a specific month.
• Function Calls: Invokes the relevant functions based on user input.
Error Handling
• User Input Validation:
• Implementation: The program employs conditional statements to validate user inputs, ensuring
they fall within expected ranges.
• Example: Checks if the user's choice for the month is between 1 and 12, and if the year is within
a reasonable range.

• Invalid Month Handling:


• Scenario: If the user enters an invalid month (e.g., less than 1 or greater than 12).
• Handling: The program provides feedback, indicating that the input is invalid, and prompts the
user to enter a valid month.

• Invalid Year Handling:


• Scenario: If the user enters a non-numeric value or a year outside a reasonable range.
• Handling: The program detects invalid entries, informs the user about the error, and prompts
them to enter a valid numeric year.

• Graceful Exit:
• Scenario: If the user decides to exit the program at any point.
• Handling: The program gracefully exits, providing a message to the user, ensuring a smooth and
user-friendly experience.

You might also like