C How to Program (8th Edition)
8th Edition
ISBN: 9780133976892
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 7, Problem 7.33MD
Program Plan Intro
- Declare prototype for three functions building_CF, car_CF and bicycle_CF.
- Inside main function,
- Declare array of function f to point to three functions building_CF, car_CF and bicycle_CF.
- Declare an integer variable choice to store the user’s choice
- Use while loop to repeatedly take user’s choice and call different function using array of function.
- Define function building_CF. Inside this function ask from user for various parameters that can contribute to CO2 emission. Based on value of these paramters and emission factor calculate the carbon foot print for building.
- Similar as above define function car_CF and bicycle_CF. The CO2 emission of car will be based on type of fuel used in it and for bicyle CO2 emission will depend on the distance travelled.
Summary Introduction: The program uses CO2 emission factors of various fuels used to calculate the carbon footprint for any building, car or bicycle. The program defines three functions for each type of carbon footprint calculation and calls them using array of function.
Program Description:The program prompts the user to enter the type of carbon footprint to calculate and then based on his/her choice uses the array of function to calculate the carbon footprint.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Using C++ Programming language:
Assume you want a function which expects as parameters an array of doubles and the size of the array. Write the function header that accepts these parameters but is defined in such a way that the array cannot be modified in the function. You can use your own variable names for the parameters.
CODE USING C++
1. Please Fix Me
by CodeChum Admin
Hi dear Programmer, I am broken.
Can you please help me fix me? ??
Instructions:
In the code editor, you are provided with a main() function that declares an array, sets its values, and then prints the sum of all of its values.
However, there is a problem with how the array is declared. The array should be able to store 5 values.
Your task is to fix the me array's declaration.
Output
25
please answer within 30 minutes.
Chapter 7 Solutions
C How to Program (8th Edition)
Ch. 7 - Answer each of the following: The _____ operator...Ch. 7 - Prob. 7.10ECh. 7 - Do each of the following: Write the function...Ch. 7 - (Simulation: The Tortoise and the Hare) In this...Ch. 7 - (Card Shuffling and Dealing Modification) Modify...Ch. 7 - What does this program do, assuming that the user...Ch. 7 - What does this program do?Ch. 7 - Find the error in each of the following program...Ch. 7 - (Maze Traversal) The following grid is a...Ch. 7 - Prob. 7.23E
Knowledge Booster
Similar questions
- c++ hw In this hw, you're going to be working with partially filled arrays that are parallel with each other. That means that the row index in multiple arrays identifies different pieces of data for the same person. This is a simple payroll system that just calculates gross pay given a set of employees, hours worked for the week and hourly rate. code format: // TODO: Add function prototypes for all the declared functions // TODO: Declare two functions to compute the highestPay and lowestPay// HINT: Each should return the index of the correct value in the grossPay array. /* TODO: Create a function calledgetEmployeeNames Arguments : Name array(first and last name) Maximum size Return the number of names filled.*/ /* TODO: Create a function calledgetHourlyPay Arguments : NameArray(filled in Step 1) HourlyPayArray(starts empty) NumberOfNamesFilled(from Step1)*/ int main(){ // TODO: Declare an array of strings for the employeeNames able to hold a…arrow_forwardHow do you define and use double indirection pointers, pointer to array and array of pointers? Give codes. C Programmingarrow_forwardBoth are different questions and write it in C++.arrow_forward
- write a code in C++ You work for a streaming analytics company and have been tasked with writing a program that analyzes views and likes on a series of YouTube videos. Code a modular program that uses parallel arrays to store views, likes, and like percentages for a series of videos. The program must do the following: The program must first ask the user for the number of videos that will be selected from YouTube. This must be done using a function that is called. For each video, the program must use random numbers to generate the number of views, likes, and the like percentage and store each value in a series of parallel arrays. These arrays must NOT be declared globally. These arrays also must be populated using a loop that calls a series of functions to generate the views, likes, and like percentage. The following arrays must be declared: views[] - an array of type long to hold the randomly generated views each YouTube video gets likes[] - an array of type long to hold the…arrow_forwardWhich of the following statements are true for static arrays in C++? Static arrays are declared with a size at compile time. (select all that are true) Every element in an array has the same base type. The array will grow dynamically to accommodate additional elements. The array elements are initialized to 0 when an array is created. O Array size must be declared by a constant expression O The array must be explicitly deleted when the programmer is done with it.arrow_forwardMark the following statements as true or false: a. To use a predefined function in a program, you need to know only the name of the function and how to use it. (1) b. A value-returning function returns only one value. (2, 3) c. Parameters allow you to use different values each time the function is called. (2, 7, 9) d. When a return statement executes in a user-defined function, the function immediately exits. (3, 4) e. A value-returning function returns only integer values. (4) f. A variable name cannot be passed to a value parameter. (3, 6) g. If a C++ function does not use parameters, parentheses around the empty parameter list are still required. (2, 3, 6) h. In C + + , the names of the corresponding formal and actual parameters must be the same. (3, 4, 6) i. A function that changes the value of a reference parameter also changes the value of the actual parameter. (7) j. Whenever the value of a reference parameter changes, the value of the actual parameter changes. (7) k. In C++, function definitions can be nested; that is, the definition of one function can be enclosed in the body of another function. (9) l. Using global variables in a program is a better programming style than using local variables, because extra variables can be avoided. (10) m. In a program, global constants are as dangerous as global variables. (10) n. The memory for a static variable remains allocated between function calls. (11)arrow_forward
- Why do you need to include function prototypes in a program that contains user-defined functions? (5)arrow_forwardAnswer msut be in C++ Write a program that will manipulate a person's name. Write a program that passes three blank character arrays into a function, asks for the user's first, last and middle name and stores each in its own character array. Upon returning to the main program create a fourth array, maipulate and combine the three array values storing the user's name in the following manner: last name, followed by a comma and space, then the user's first name and middle initial only (followed by a period), separated by a space. For example, if your name is "Jill Saint John", the value stored in the fourth array should be "John, Jill S." Display the contents of the fourth array on the screen.arrow_forwardin c++arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr