
Jeff B. answered 02/01/22
Master's degree in Computer Science and 6+ years industry experience
I can't do your homework for you, but I'll post similar answers so you get the idea.
1) A struct combines multiple member variables into a single record.
- To add string information like names, I create character array fields, such as char hostname[21]. The number of entries in the array goes inside the square brackets. Make sure that number is big enough to include all values you would want to have in there, plus an extra null terminating character 0.
- To add decimal numbers, I create float fields, such as float cost.
2) Here's an example of an array using the Computer struct again:
Programs consist of several segments, which are regions of memory that contain different kinds of data:
- code - instructions
- data - initialized global variables
- read-only data - initialized read-only global variables and strings
- stack - local variables
- heap - dynamically allocated memory (allocated with malloc, calloc, etc.)
- bss - uninitialized global variables
Which one do you think your global variables are stored in? Pay attention to whether they are initialized or not, and keep in mind that your instructor may not accept "bss" as an answer even if it's the best fit.
For question 3, here's an example program:
I hope that gives you a good start (without giving away the answers). Let me know if you'd like to book a session to get some more help!
Amani A.
very helpful thnx alot . but what about the other parts , they are more complicated02/01/22