Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Instructions: C++ a) Use scanf function to accept the input from the user. b) Use floating point inputs wherever possible. c) Provide the output 1.
Instructions: C++ a) Use scanf function to accept the input from the user. b) Use floating point inputs wherever possible. c) Provide the output 1. a) Define a structure with the tag Consumption to consist of a character array (city[20]), an integer (year), and a double (usage). b) Define a structure with the tag Resource to consist of two character arrays (material [30], and units [20]), and three doubles (longitude, latitude, and quantity). Then in the main function, declare metal and fuel to be variables of type struct Resource, and then declare water and power to be variables of type struct Consumption. Declare one more variable wood of type struct Resource with the members of wood to be initialized as per Table I: TABLE I. Member for structure variable wood Value material[30] Oak longitude 32.5 latitude 13.2 quantity 5e+8 5e+8 units[20] hectares Then, use the dot operator (.) or special string functions (wherever applicable) to assign the following values to the members of the various structure variables as per Table II. TABLE II. Variable name Member name Value longitude 57.3 latitude 32.1 metal quantity 3e+10 material Iron units cubic meters Then use the printf() function to print all these numerical values using their respective data type placeholders. Finally, use the scanf() function to input numerical values from the user regarding the values of the following members (a) fuel (b) water (c) power Then print these values which were given as input by the user using the printf() function. [Note: When you use special string functions, you have to use the #include
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