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

How do I program a game using C program?
Programming a game in C involves several steps. Here's a simplified guide to get you started: Define Your Game Concept: Clearly outline the game's concept, rules, and objectives. Setup Your Development...
Sumitha
0 0
6
Can you suggest me some books for learning C?
"letus c" for c programming yashwant kanetkar
Yamun
Can we have if inside else-if or else in C programming language?
Yes it is possible to do so. The if... else if..... else statements support one other inside themselves... so...
Kirthi
Other than in a for statement, when is the comma operator used?
Example : int i,j; i=(10,20,30,40); j=10,20,30,40; printf("%d",i); printf("%d",j); // in this program output of i will be 40 and j will be 10 // In interviews you can face such type of comma operator related questions.
Sanjay
What is the difference between compile time error and run time error?
Compile error is the error when you check for syntax error while run time error comes when you do execution of the program.
Varada
0 0
6

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

Ask a Question

Related Lessons


What is a Programming Language
What is a Language? Language is a communication system of human. What is a programming Language? A programming Language is a formal constructed language design to communicate...

C PROGRAM FOR GENERATING SOUND
#include<stdio.h> #include<conio.h> #include<dos.h> void main() { sound(3000); // sound function have single parameter , this parameter we put integer value its generating...

V. Muthu Ganeshan

0 0
0

Software Development Training In Jaipur
Satyam Web Solution provides website designing &development and software designing &development training in Jaipur for various stream’s students. MCA 6 month Industrial Training/Internship B....

C Program to print Block Letter and Small Case Alphabets using C
/* WAP to print Block Letter and Small Case Alpahbets using C*/ //Hint:use ascii code(value) to print #include#include void main(){ int i; clrscr(); //Block Letters Alphabets printf("Block Letters Alphabets\n");...

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