UrbanPro

Learn C Language from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

What is the program for print calendar?

Asked by Last Modified  

Follow 0
Answer

Please enter your answer

Computer Teacher

int fm(int date, int month,year) { int fmonth, leap; //leap function 1 for leap & 0 for non-leap if ((year % 100 == 0) && (year % 400 != 0)) leap = 0; else if (year % 4 == 0) leap = 1; else leap = 0; fmonth = 3 + (2 - leap) * ((month + 2) / (2 * month)) ...
read more
int fm(int date, int month,year) { int fmonth, leap; //leap function 1 for leap & 0 for non-leap if ((year % 100 == 0) && (year % 400 != 0)) leap = 0; else if (year % 4 == 0) leap = 1; else leap = 0; fmonth = 3 + (2 - leap) * ((month + 2) / (2 * month)) + (5 * month + month / 9) / 2; //bring it in range of 0 to 6 fmonth = fmonth % 7; return fmonth; } //---------------------------------------------- int day_of_week(int date, int month, int year) { int dayOfWeek; int YY = year % 100; int century = year / 100; printf("\nDate: %d/%d/%d \n", date, month, year); dayOfWeek = 1.25 * YY + fm(date, month, year) + date - 2 * (century % 4); //remainder on division by 7 dayOfWeek = dayOfWeek % 7; switch (dayOfWeek) { case 0: printf("weekday = Saturday"); break; case 1: printf("weekday = Sunday"); break; case 2: printf("weekday = Monday"); break; case 3: printf("weekday = Tuesday"); break; case 4: printf("weekday = Wednesday"); break; case 5: printf("weekday = Thursday"); break; case 6: printf("weekday = Friday"); break; default: printf("Incorrect data"); } return 0; } //------------------------------------------ int main() { int date, month, year; printf("\nEnter the year "); scanf("%d", &year); printf("\nEnter the month "); scanf("%d", &month); printf("\nEnter the date "); scanf("%d", &date); day_of_week(date, month, year); return 0; } read less
Comments

unix command 'cal'
Comments

Eminent Teacher of Computer Science

I can teach you to print a calendar. but just getting a code and submitting the assignment is not good for your future. You have to learn the logic.
Comments

Engineering Trainer

cal is the command line application in Linux to print calendar
Comments

Perl Developer | Perl Trainer

There is a CPAN module 'Calendar::Simple', you can use in Perl program to print a simple calendar.
Comments

Trainer

Before sharing a program I would like to explain the program and logic within - please get in touch with me.
Comments

Tutor

#include stdio.h #define TRUE 1 #define FALSE 0 int days_in_month={0,31,28,31,30,31,30,31,31,30,31,30,31}; char *months= { " ", "\n\n\nJanuary", "\n\n\nFebruary", "\n\n\nMarch", "\n\n\nApril", "\n\n\nMay", "\n\n\nJune", "\n\n\nJuly", "\n\n\nAugust", "\n\n\nSeptember", "\n\n\nOctober", "\n\n\nNovember", "\n\n\nDecember" }; int...
read more
#include stdio.h #define TRUE 1 #define FALSE 0 int days_in_month[]={0,31,28,31,30,31,30,31,31,30,31,30,31}; char *months[]= { " ", "\n\n\nJanuary", "\n\n\nFebruary", "\n\n\nMarch", "\n\n\nApril", "\n\n\nMay", "\n\n\nJune", "\n\n\nJuly", "\n\n\nAugust", "\n\n\nSeptember", "\n\n\nOctober", "\n\n\nNovember", "\n\n\nDecember" }; int inputyear(void) { int year; printf("Please enter a year (example: 1999) : "); scanf("%d", &year); return year; } int determinedaycode(int year) { int daycode; int d1, d2, d3; d1 = (year - 1.)/ 4.0; d2 = (year - 1.)/ 100.; d3 = (year - 1.)/ 400.; daycode = (year + d1 - d2 + d3) %7; return daycode; } int determineleapyear(int year) { if(year% 4 == FALSE && year%100 != FALSE || year%400 == FALSE) { days_in_month[2] = 29; return TRUE; } else { days_in_month[2] = 28; return FALSE; } } void calendar(int year, int daycode) { int month, day; for ( month = 1; month <= 12; month++ ) { printf("%s", months[month]); printf("\n\nSun Mon Tue Wed Thu Fri Sat\n" ); // Correct the position for the first date for ( day = 1; day <= 1 + daycode * 5; day++ ) { printf(" "); } // Print all the dates for one month for ( day = 1; day <= days_in_month[month]; day++ ) { printf("%2d", day ); // Is day before Sat? Else start next line Sun. if ( ( day + daycode ) % 7> 0 ) printf(" " ); else printf("\n " ); } // Set position for next month daycode = ( daycode + days_in_month[month] ) % 7; } } int main(void) { int year, daycode, leapyear; year = inputyear(); daycode = determinedaycode(year); determineleapyear(year); calendar(year, daycode); printf("\n"); } read less
Comments

update calendar program
Comments

Learn C with Data Structure / Network / Unix System Programming

cal
Comments

Asst. Professor at Jiwaji University, Gwalior

You can write a program to print Calendar in C Language after joining my C Language Online Tutorial Course for any query mail me.
Comments

View 12 more Answers

Related Questions

C machine independent Programming Language? C is portable . Means What?
It can work on various hardware configuration . C doesnt require mandatory or same set of hardware to run program. A program can written on one comp. And can run on other comp.(machine)
Shiva
Can a file other than a .h file be included with #include?
Yes. user defined header file ex:#include "nim.c"
Pankaj
0 0
7
Can include files be nested?
one line can only include one directory. No nesting is applicable.
Himangi
0 0
7
How can I learn C easily and rapidly?
You can learn C by three ways 1. Practise 10 programs daily for 10 days. 2. Understand the programming concept before going to make an attempt 3. Try to do some simple projects on your own will improve your skills rapidly.
Umamahesh
0 0
5

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Array vs Linked List
Array Linked List Accessing element is easy. Accessing element is difficult compare to Array. Easy to use. Difficult to use. Memory is Fixed size. Memory is variable size. If...

Java and C trainer
Always think any conspect with real-time example like Object -- object must have states and behaviour then only we will call that thing is Object like fan is Object (rotating,color)

How to write shared library program using C Programming?
Library Name : hellofilename : hello.c#include void Hello(){ printf("Hello World .. How are you 1\n");}======================================Header File:hello.h#ifndef __HELLO_H#define __HELLO_Hvoid Hello(void);#endif===============================Application...

Find out the Output of the following with reason and get C Language Training fess less by 10%
1. void main() { clrscr(); printf(5+"Beautifull"); getch(); } 2. void main() { int a=50; clrscr(); ...

Some interview questions and answers for fresher level on Pointers
What is a void pointer? Void pointer is a special type of pointer which can reference or point to any data type. This is why it is also called as Generic Pointer. As a void pointer can point to...

Recommended Articles

Brilliant Academy is one of the reputed institutes for B.Tech tuition classes. This institute is specialised in delivering quality tuition classes for B.E, Engineering - all streams and Engineering diploma courses. Incorporated in 2012, Brillant Academy is a brainchild of Mr Jagadeesh. The main motto of the academy is to...

Read full article >

Lasya Infotech is a Hyderabad based IT training institute founded in 2016 by O Venkat. Believing in his innovation, passion and persistence and with a diverse blend of experience, he started his brainchild to deliver exemplary professional courses to aspiring candidates by honing their skills. Ever since the institute envisions...

Read full article >

Microsoft Excel is an electronic spreadsheet tool which is commonly used for financial and statistical data processing. It has been developed by Microsoft and forms a major component of the widely used Microsoft Office. From individual users to the top IT companies, Excel is used worldwide. Excel is one of the most important...

Read full article >

Almost all of us, inside the pocket, bag or on the table have a mobile phone, out of which 90% of us have a smartphone. The technology is advancing rapidly. When it comes to mobile phones, people today want much more than just making phone calls and playing games on the go. People now want instant access to all their business...

Read full article >

Looking for C Language Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for C Language Classes?

The best tutors for C Language Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn C Language with the Best Tutors

The best Tutors for C Language Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more