Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The goal of this tutorial and assignment is to both motivate the use of heterogeneous aggregates (called structures in C) and introduce you to some
The goal of this tutorial and assignment is to both motivate the use of heterogeneous aggregates (called structures in C) and introduce you to some of the many ways they can be useful in programming. So, let's start with how one declares a structure in C. The code, struct studentData char lastName [30) char first Name [ 30 char idNum (91: int exam1 int exam2; int exam3 float avga char grade ) student: // makes a variable called student which is a struct with Freras as defined above. Each of the "fields" as they are called has a declaration like you've seen before. To access a field of a struct (student in this case) we use the So, if we wished to say that our hypothetical student received a 75 on exam 1, we could just do an assignment, such as student.examl 75; In fact, this might be a good time for you to copy all of the files (and directories) in the tutorial directory to one of your own. I'm sure you already know how to do this having been copying files all term long, but the "magic" command is: cp -r -dmk0080/public/1040/hwk/one/tutorial Make sure that you include both the (for recursive) and the ' at the end to indicate where to place the copy of that directory. If you have any questions at all about how this command works, ask someone, a TA or grader, or a peer mentor if one is available One of the files that you just copied is a C file, called simpleExample.c, which uses the very structure definition listed above. Look at the code to see how structure fields (of "student") are accessed in both the scanf and printf statements. At this point in the term your probably understand why some fields in the scanf include an & and others don't. But if not, ask someone. Go ahead and run the simpleExample.c program, but typing gcc simpleExample.c ./a.out
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started