# Program to compute the decay rate using Euler Algorithm.

Date Posted: 11/19/2012 2:28:36 AM

Posted By: ** sollo** Membership Level:

**Bronze**Total Points:

**25**

The principle of radioactive decay states that “the rate of decay of atoms is inversely proportional to the number of atoms in a particle”. This rate can be determined using a computer program written in ” C language” as the one below.

PROGRAM TO COMPUTE THE DECAY RATE USING THE EULER ALGORITHM

// Program to compute the decay rate using the Euler algorithm

#include

Intmain()

{

// declaring variables

Double NO; // Number of atoms at time To;

Double N; // number of atoms remaining at time t

Double dN; // initial values of

Double To;// start time

Double T;

Double dt;//time step

Double lambda=1 decay constant

// entering data

Cout<<” \n enter the initial number of atoms, No=”;

Cin>>No;

Cout<<”\n enter starting time, To=”;

Cin>>TO;

COUT<<”\n enter the time step, dt=”;

Cin>>dt;

// to print the titles

Cout<<”time”<<\t”rate”<<”\t”<<”number of atoms remaining, N;

Cout<<”\n”;

// to compute the values of T,rate,dN, and N;

N=NO;

T=TO;

While (T<=5)

{

Double rate=- lambda*N;

Dn=Rate*dt;

N=N+Dn;

Cout<

T=T+dt;

}

Return 0;

}

When building and executing this program , you will be asked to enter the initial number of atoms, No,starting time, To add also to enter the time step in order to compute the values of T,rate,dN, and N;

This will give a computational value at the above specified variables during the first five hours.

**Next:** Learn how to prepare ''coconut fish balls''**Previous:** Ways of getting rid of too much time you spend on facebook