**Please explain why invalid** Consider the following statements struct nameType
ID: 3909256 • Letter: #
Question
**Please explain why invalid**
Consider the following statements struct nameType struct courseTy stuct studentType string firat; string last; atring name; int callNum int creditsi char grade; nameType namei double gpa; courseType course: 2: )i studentType student studentType classList [1001 courseType coursei n?eType name ; Mark the following statements as valid or invalid. If a statement is invalid, explain why. (2, 3, 6, 7, 8) a. student.gpa3.76 b. student.name.last- "Anderson" c. classList [1]·name = student ; d. c1a88List [0].ca11Nurn= 0; e. 8 tudent. name - c1a88L?8t [10] . name; f. course = classList[0]; g. cinExplanation / Answer
Solution: -
classList[j].course = course;
The statements are completely fine as here we are populating the course field of studentType structure variables present in the classList array.
classList.name.last = “ ” ; this statement is invalid as we classList is an array and not a studentType structure variable
course.credits = studentType.course.credits; this is invalid as we can make reference to a structure field by using the structure variable i.e. student here in this context and not studentType. So the correct one should be course.credits = student.course.credits;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.