hiii, i am so proud to be on of you , i am really happy to learn more and more about c language and i have assignment . and i would like to help me please. i don't have enough time so plzz. the question is : Write a C program the print the calendar of certain month. This can be done by asking the user to enter the starting day of the month and the number of days in these months. thank you. kissesxoxoxo
Not really tested, but maybe it works... I'm too sleepy to argue with it any longer. :biggrin: Code: #include <stdio.h> #include <string.h> char *CAL[] = { "sun", "mon", "tue", "wed", "thu", "fri", "sat" }; int main(void) { char input[] = "mon 31"; int i, offset, ndays; sscanf(input + 3, "%d", &ndays); puts(" S M T W T F S \n"); for(i=0; i < 7; ++i) if(strncmp(input, CAL[i], 3) == 0) break; offset = i; i = 0; while(i < offset) { printf(" "); ++i; } i = 1; while(i <= ndays) { if((i + offset - 1) % 7 == 0) putchar('\n'); printf(" %2d ", i); ++i; } puts("\n\ndone..."); return 0; }
Write a C program the print the calendar of certain month. This can be done by asking the user to enter the starting day of the month and the number of days in these months plzzzzzz try again
Write a C program the print the calendar of certain month. This can be done by asking the user to enter the starting day of the month and the number of days in these months. I don't follow what you're asking. What are "calendar of certain month" and "starting day of month" supposed to be in terms of a program? If a user enters those parameters, what is he or she being asked to enter? A text representation for the day of the week, a numerical representation of the day, etc. Similarly, what month is supposed to be printed and for what year? All months having X number of days? The first month having X days, etc There isn't enough information provided to determine how to go about finding a possible solution... well for me at least. [edit] shabbir was holding out . I like that - thanks. fflush(stdin) - naughty naughty. [/edit]