# Thread: finding amount of cobalt need help

1. ## finding amount of cobalt need help

Question:
The rate of decay of a radioactive isotope is given in terms of its half time H, the time lapse required for the isotope to decay to one-half of its original mass.The isotope cobalt-60 has a half-life of 5.272 years. Compute and print in table form the amount of this isotope that remains after each year for 5 years, given the initial presence of an amount in grams. the value of amount should be provided interactively. the amount of cobalt-60 remaining can be computed by using the following formula: r=amount X C^(y/H) where amount is the initial amount in grams, c is expressed as e^-0.693 (e=2.71828), y is the number of years elapsed, and H is the half-life of the isotope in years.
Code:
```#include <stdio.h>
#include <math.h>
int
main(void)
{
int year;
double cobalt_initial;
printf("Please enter the initial amount of Cobalt> ");
scanf("%lf", &cobalt_initial);
printf(" Year     Amount Total\n");
for (year = 0; year <= 5; year += 1){
cobalt_initial = cobalt_initial - cobalt_initial * exp((-.0693)*(year/(5.272)));
printf("%6c%d%8c%.2f\n", ' ', year, ' ', cobalt_initial);
}
return(0);
}```
the program, instead of making a table for every year does this:
Please enter the initial amount of Cobalt> 200
Year Amount Total
6 0.00

2. The first iteration through the loop year is zero, so the argument to exp() is zero. exp(0) is always 1. So the first time through the loop sets cobalt_initial to zero. On subsequent iterations, since cobalt_initial is zero, it's value doesn't change - cobalt_initial is a common factor in all terms of the expression.

The code should print six lines, with a value of cobalt_initial being zero for each year. If you are not getting that, you have a version control problem.

And your code formatting is atrocious.

I've described what the code is doing. It is your job to make it do what you intend, not mine.

3. I fixed the equation. How can I fix the version control problem, it doesn't print six lines. Please help me. It seems like I did everything right....I'm confused. Thanks for any help!

4. Make sure the code you're working with is identical to what you posted. Make the required changes. Then delete the executable and object files. Recompile the code and link.

If using an IDE (Integrated Development Environment, like CodeBlocks, Visual Studio, or whatever it is you are using) do "Build Clean" (to delete the executable and object files) followed by "Build All" (to recompile and link). [The wording of those actions in quotes vary between IDEs, but the idea is the same].

5. You should know that this is C, not C++, so please post in the C section next time.