Question: Please write this in C + + using a while and if loop. Radioactive Decay This problem is based on the explanation of Chapter 5

Please write this in C++ using a while and if loop. Radioactive Decay
This problem is based on the explanation of Chapter 5 Problem #14. That problem describes how you
calculate radioactive decay from a half life. This is the function you must build:
// Chapter 5 question /4
int years_to_decay(double starting_amount, double target);
Given a start_amount of Cobalt-60 and a target for how radioactive you want it to be, you must compute
how many whole years it will take to get below that target. The return type of this is an int, so you can just
walk through years from 1 to whatever until the amount remaining is less than the target.
With C, there's a little complication to this. You need the constant for e. If you include math.h, you'll get
a constant M_E that evaluates to e. That include file also gives you pow (x,y) that raises x to the yth power.
However, there's where the complication comes. In order to make the compiled files as small as possible,
the linker only includes the bare minimum functionality. I think that requires a bit more explanation ...
So, with this project, our code is in two separate .c files. The compiler actually compiles each of them
separately. Then another program, called the linker, puts those compiled files together to build the runnable
file. The linker also includes code for things like printf. However, in order to keep our executables small,
the linker only includes the bare minimum of extra libraries. We're going to have to figure out how to tell
it to include the math library. (Yes, it feels like we did that when we included math.h. That was enough to
make it compile, but the .h file only includes descriptions of the code. Now we have to tell the linker where
to find the functions that math.h referred to.) There's one more file in your project that is telling the machine
how to put the stuff together to build your executable. CMakeLists.txt:
cmake_minimum_required(VERSION 3.16)
project (Loops ?-
 Please write this in C++ using a while and if loop.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!