Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2022 Grenoble France September 19 23 2022 Proceedings Part 4 Lnai 13716

Authors: Massih-Reza Amini ,Stephane Canu ,Asja Fischer ,Tias Guns ,Petra Kralj Novak ,Grigorios Tsoumakas

1st Edition

3031264118, 978-3031264115

More Books

Students also viewed these Databases questions

Question

What questions does the Simple Form Wizard ask?

Answered: 1 week ago

Question

Write a Python program to check an input number is prime or not.

Answered: 1 week ago