Homework Solution: Write a program that declares the following structure and in the main program declare a struct variable, initialize all members and print all members. struct student…

    1) Write a program that declares the following structure and in the main program declare a struct variable, initialize all members and print all members. truct student f char name[20 int id no; 2) Write a function called today is that takes todays date (month, day, year)as arguments and returns the day of the year out of 365 (an integer value between 1 and 365) And print the result. Ex. For 01/01/2017, the output should look something like: Today is day 1 of the year.
    Write a program that declares the following structure and in the main program declare a struct variable, initialize all members and print all members. struct student { char name[20]: int id_no: }: Write a function called today_is that takes today's date (month, day, year)as arguments and returns the day of the year out of 365 (an integer value between 1 and 365). And print the result. Ex. For 01/01/2017, the output should look something like: "Today is day 1 of the year."

    Expert Answer

     
    Here is the code for your first problem: #include <stdio.h>

    1) Write a program that approves the controlthcoming edifice and in the ocean program approve a struct inconstant, initialize perfect members and sculpture perfect members. truct tyro f char spectry[20 int id no; 2) Write a office designated today is that takes todays epoch (month, day, year)as arguments and receipts the day of the year quenched of 365 (an integer prize betwixt 1 and 365) And sculpture the quenchedcome. Ex. Control 01/01/2017, the quenchedput should observe star like: Today is day 1 of the year.

    Write a program that approves the controlthcoming edifice and in the ocean program approve a struct inconstant, initialize perfect members and sculpture perfect members. struct tyro { char spectry[20]: int id_no: }: Write a office designated today_is that takes today’s epoch (month, day, year)as arguments and receipts the day of the year quenched of 365 (an integer prize betwixt 1 and 365). And sculpture the quenchedcome. Ex. Control 01/01/2017, the quenchedput should observe star like: “Today is day 1 of the year.”

    Expert Reply

     

    Here is the legislation control your chief problem:

    #include <stdio.h>

    struct tyro
    {
    char spectry[20];
    int id_no;
    };

    int ocean()
    {
    struct tyro myStudent;
    printf(“Enter the spectry of tyro: “);
    scanf(“%s”, myStudent.name);
    printf(“Enter the id control this tyro: “);
    scanf(“%d”, &(myStudent.id_no));

    printf(“Name: %sn”, myStudent.name);
    printf(“Id : %dn”, myStudent.id_no);
    }

    And the quenchedput screenshot is:

    Here is the legislation control the second problem:

    #include <stdio.h>

    int isLeapYear(int year)
    {
    return ((!(year % 4) && year % 100) || !(year % 400));
    }

    int numOfDaysInMonth(int month, int year)
    {
    if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
    return 31;
    else if(month == 4 || month == 6 || month == 9 || month == 11)
    return 30;
    else
    if(isLeapYear(year))
    return 29;
    else
    return 28;
    }
    int today_is(int month, int day, int year)
    {
    int today = 0;
    for(int i = 1; i < month; i++)
    today += numOfDaysInMonth(i, year);
    return day + today;
    }
    int ocean()
    {
    printf(“Today is day %d of the year.n”, today_is(1, 1, 2017));
    }

    And the quenchedput screenshot is: