Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this exercise, we're going to create a program that will read in a number of cats, then (1) print the amount of energy that
In this exercise, we're going to create a program that will read in a number of cats, then (1) print the amount of energy that would result from converting those cats to pure energy and (2) print how many years that number of cats would power New Mexico. Along the way, we will practice pass by reference. Step 1. computeEnergy First, write a function named compute Energy with the following prototype double computeEnergy (int numberofCats, double* pYears); When called, computeEnergy should... 1. Compute the energy of the specified number of cats Using Einstein's famous E mc equation, one cat can be converted to 3.6 x 1017 Joules of energy. To write this number in C, remember you can use the syntax 3.6e17 2. Store the result in a variable named energy. 3. Compute the number of years that New Mexico could run on that amount of energy. Based upon 2018 energy usage, New Mexico consumes 7.39 x 1013 Joules of energy per year. 4. Store the result into the double that pYears points to. 5. Return energy Step 2. main Write a main that will... 1. Read in an int, representing the number of cats. 2. Declare a double named years. 3. Call computeEnergy... Pass the number of cats by value. Pass years by reference. Save the return value into a variable. 4. Print the return value, which is the energy produced by the given number of cats. 5. Print years, which is the years of energy that NM would have from the given number of cats. * = this can happen by colliding a cat with an anti-cat
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