Question: C. Struct 2 (25 points) We have seen that a struct can contain all the familiar variables char, int, double. It can also contain arrays,
C. Struct 2 (25 points) We have seen that a struct can contain all the familiar variables char, int, double. It can also contain arrays, strings (which are arrays of characters), and pointers. This second exercise will focus on using arrays as members within a struct. Our theme for a program to see how this works is a mini set of medical records. 1. Start by defining a struct template that has the following members: a. a patient ID number, which is some integer between 1 and 100000. b. a patient name in the form of a character array just a single first name is adequate. c. a three-element array of integer for the month, day, and year (eg. 4, 2, 2018). d. a double for body temperature, e. a integer for weight (in pounds), f. a integer for height (in inches), g. a two-element array of integers for blood pressure (110, 70). h. a double for body-mass index. 2. Once the struct is defined, declare an instance of the struct variable. 3. Fill items a - g with reasonable numbers for a typical human being. You can simply assign values to the various members this probably the easiest approach or you can use scanf() to have the user enter the values. Either way will be will be slightly tedious.Note that you will probably want to use strcpy() to initialize the name string. 4. Then calculate the BMI (body-mass index) from the height and weight and assign the value to the bmi member. 5. Finally, print our the patients records. Note, you can certainly implement some of these actions with functions, although functions are not a requirement.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
