Ask Question
16 July, 03:32

Define a function SetBirth, with int parameters monthVal and dayVal, that returns a struct of type BirthMonthDay. The function should assign BirthMonthDay's data member month with monthVal and day with dayVal.

#include

typedef struct BirthMonthDay_struct {

int month;

int day;

} BirthMonthDay;

/ * Your solution goes here * /

int main (void) {

BirthMonthDay studentBirthday;

int month;

int day;

scanf ("%d %d", &month, &day);

studentBirthday = SetBirth (month, day);

printf ("The student was born on %d/%d./n", studentBirthday. month, studentBirthday. day);

return 0;

}

+3
Answers (1)
  1. 16 July, 05:28
    0
    The method definition to this question can be described as follows:

    Method definition:

    BirthMonthDay SetBirth (int monthVal, int dayVal) / /defining method SetBirth

    {

    BirthMonthDay type; / /defining structure type variable

    type. month = monthVal; / /holding value

    type. day = dayVal; //holding value

    return type; / /retrun value

    }

    Explanation:

    Definition of the method can be described as follows:

    In the above method definition a structure type method "SetBirth" is defined, that accepts two integer parameter, that is "monthVal and dayVal". This method uses typedef for declaring the structure type method. Inside the method, a structure type variable that is "type" is declared, which holds the method parameter value and uses the return keyword to return its value.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Define a function SetBirth, with int parameters monthVal and dayVal, that returns a struct of type BirthMonthDay. The function should ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers