C assignment
ANybody tell me what the problem is here? Im sure its something rediculously simple I just cant see it.
Bruce
/* File: decay.c
Programmer: Bruce Reid Date: October 11, 2004
COurse: ENGM2081
The time decay of a radioactive isotope is given in terms of its
half-life, H, the time lapse required for the isotope to decay to
one-half of its original mass. The isotope strontium 90 has
a half-life of H= 28 years.
This program computes and prints in table form (to screen and to the
file decay.out) the amount oh this isotope that remains after each year
up to n years, given initial amoun tin grams.
The values of n and initial amount are read interactively. The amount
of Sr90 remaining after y years can be computed from the formula:
amount = (initial_amount)2^(-y/H)
*/
#include
Bruce
/* File: decay.c
Programmer: Bruce Reid Date: October 11, 2004
COurse: ENGM2081
The time decay of a radioactive isotope is given in terms of its
half-life, H, the time lapse required for the isotope to decay to
one-half of its original mass. The isotope strontium 90 has
a half-life of H= 28 years.
This program computes and prints in table form (to screen and to the
file decay.out) the amount oh this isotope that remains after each year
up to n years, given initial amoun tin grams.
The values of n and initial amount are read interactively. The amount
of Sr90 remaining after y years can be computed from the formula:
amount = (initial_amount)2^(-y/H)
*/
#include
[Error: Irreparable invalid markup ('<stdio.h>') in entry. Owner must fix manually. Raw contents below.]
ANybody tell me what the problem is here? Im sure its something rediculously simple I just cant see it.
Bruce
<lj-cut text="PRoblem">
/* File: decay.c
Programmer: Bruce Reid Date: October 11, 2004
COurse: ENGM2081
The time decay of a radioactive isotope is given in terms of its
half-life, H, the time lapse required for the isotope to decay to
one-half of its original mass. The isotope strontium 90 has
a half-life of H= 28 years.
This program computes and prints in table form (to screen and to the
file decay.out) the amount oh this isotope that remains after each year
up to n years, given initial amoun tin grams.
The values of n and initial amount are read interactively. The amount
of Sr90 remaining after y years can be computed from the formula:
amount = (initial_amount)2^(-y/H)
*/
#include <stdio.h>
int main(void)
{
FILE* outfile;
outfile = fopen("ftest.out", a) ;
float initialamount, amount, y, n, exponent ;
float H=28.0;
printf("How many grams of Strontium did you begin with?") ;
scanf("%f", &initialamount) ;
printf("\nHow many years has the sample been decaying?") ;
scanf("%f", &y) ;
for(n=0; n<=y ; n++)
{
exponent = pow(2,(-n/H);
amount= (initialamount)*exponent ;
printf("Year: %f\tAmount Remaining: %f",n,amount);
fprintf(outfile, "Year: %f\tAmount Remaining: %f",n,amount);
}
return 0;
}
</lj-cut>
Bruce
<lj-cut text="PRoblem">
/* File: decay.c
Programmer: Bruce Reid Date: October 11, 2004
COurse: ENGM2081
The time decay of a radioactive isotope is given in terms of its
half-life, H, the time lapse required for the isotope to decay to
one-half of its original mass. The isotope strontium 90 has
a half-life of H= 28 years.
This program computes and prints in table form (to screen and to the
file decay.out) the amount oh this isotope that remains after each year
up to n years, given initial amoun tin grams.
The values of n and initial amount are read interactively. The amount
of Sr90 remaining after y years can be computed from the formula:
amount = (initial_amount)2^(-y/H)
*/
#include <stdio.h>
int main(void)
{
FILE* outfile;
outfile = fopen("ftest.out", a) ;
float initialamount, amount, y, n, exponent ;
float H=28.0;
printf("How many grams of Strontium did you begin with?") ;
scanf("%f", &initialamount) ;
printf("\nHow many years has the sample been decaying?") ;
scanf("%f", &y) ;
for(n=0; n<=y ; n++)
{
exponent = pow(2,(-n/H);
amount= (initialamount)*exponent ;
printf("Year: %f\tAmount Remaining: %f",n,amount);
fprintf(outfile, "Year: %f\tAmount Remaining: %f",n,amount);
}
return 0;
}
</lj-cut>
