Answered step by step
Verified Expert Solution
Question
1 Approved Answer
For each of the following descriptions: (i) Write a suitable type declaration (or set of type declarations) for representing the data. ii) Show how to
For each of the following descriptions: (i) Write a suitable type declaration (or set of type declarations) for representing the data. ii) Show how to dynamically allocate the necessary memory, and initialise any obvious fields Assume that all strings have an upper limit of 139 characters sible to use and manipulate all the information through a single pointer variable.) (a) A planet, consisting of a name, number of moons, and distance from the sun in kilometres (b) A set of instructions for finding buried treasure and the value of the treasure. Each instruction consists of a direction (north, south, east or west) and a distance in metres to travel Assume that there is a pre-existing variable num that indicates how many in structions there will be. (c) A recipe, consisting of a name and a collection of ingredients. Each ingredient itself has a name and an amount in kilograms (a real number). There is no upper limit on the number of ingredients, but you can assume the required number has previously been determined and stored in the int variable ingreds
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