Files
learning-cpp/RadioactiveDecay/main.cpp
2025-11-04 23:25:04 +01:00

27 lines
509 B
C++

#include <iostream>
#include <cmath>
using namespace std;
int N(int N0, float t, float t12)
{
return N0 * pow(.5, (t/t12));
}
int main()
{
float t12;
int N0;
float t;
cout << "What's the half-life of your isotope?: ";
cin >> t12;
cout << "What's the initial population N0?: ";
cin >> N0;
cout << "What time t do you want to evaluate N(t)? (use same unit of time): ";
cin >> t;
cout << "The population at time " << t << " is " << N(N0, t, t12);
return 0;
}