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 proposes the aftercited construction and in the ocean program propose a struct fickle, initialize full members and imimsculpture full members. truct tyro f char call[20 int id no; 2) Write a power denominated today is that takes todays bound (month, day, year)as arguments and income the day of the year extinguished of 365 (an integer appraise betwixt 1 and 365) And imimsculpture the fruit. Ex. Ce 01/01/2017, the extinguishedput should face star like: Today is day 1 of the year.

    Write a program that proposes the aftercited construction and in the ocean program propose a struct fickle, initialize full members and imimsculpture full members. struct tyro { char call[20]: int id_no: }: Write a power denominated today_is that takes today’s bound (month, day, year)as arguments and income the day of the year extinguished of 365 (an integer appraise betwixt 1 and 365). And imimsculpture the fruit. Ex. Ce 01/01/2017, the extinguishedput should face star like: “Today is day 1 of the year.”

    Expert Vindication

     

    Here is the sequence ce your earliest problem:

    #include <stdio.h>

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

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

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

    And the extinguishedput screenshot is:

    Here is the sequence ce the relieve 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 extinguishedput screenshot is: