Elementary questions about C programming

Updated on technology 2024-04-05
4 answers
  1. Anonymous users2024-02-07

    First determine whether the year is a leap year (divisible by 4) according to the number of years, and then determine which array to use:

    const int leap_year[12] = ;Leap years from January to December The number of days per month.

    const int normal_year[12] = ;The number of days in each month from January to December in a common year.

    Then calculate the day based on the number of months and days entered.

    Attached is the full procedure:

    #include

    const int leap_year[12] = ;Leap years from January to December The number of days per month.

    const int normal_year[12] = ;The number of days in each month from January to December in a common year.

    main()

    int i = 0;

    int result = 0;

    int temp = 0;

    int week = 0;

    int offset = 0;

    int day,month,year;

    int *p;

    printf("Please enter the year");

    scanf("%d",&year);

    printf("Please enter a month");

    scanf("%d",&month);

    printf("Please enter a day");

    scanf("%d",&day);

    if(!(year%4))

    p = leap_year;

    elsep = normal_year;

    for(i=0;i<(month - 1);i++)

    temp += *p;Count all the days in the previous months.

    p++;result = temp + day;Add the number of days in the month at the end and you're the final result.

    if((result%7)>=2)

    offset = 1;

    elseoffset = 0;

    week = result/7+offset;

    printf("Today is the %d day of the %d year, the %d week",year,result,week);

  2. Anonymous users2024-02-06

    Is this needed? It's easy, right?

  3. Anonymous users2024-02-05

    Easy? Junior? Tell me what week is April 8, 1954?

  4. Anonymous users2024-02-04

    This software should be able to add up the years, months and days in the week, seven days a week, calculate the first day of a year is the day of the week of the first week, and then divide the number of days by seven, and then choose according to the remainder.

Related questions
10 answers2024-04-05

You start by writing a function to find a sequence.

Then use for or while to call the !! >>>More

25 answers2024-04-05

First think about how many parts the whole program needs, and then what functions each part needs, and then think about the process of each part, the global variables needed, and then make it up according to the content of the design.

4 answers2024-04-05

The introductory course of MCU C language programming is not difficult, it is not easy to say, and the first thing to understand is to understand what these two things are when learning MCU C language? The introductory programming of single-chip microcomputer is mainly to learn C language, followed by circuit and programming language. >>>More

8 answers2024-04-05

Program Problem 1: include

int main(void) >>>More