Write an algorithm to find the energy
produced at every second if the
reaction is allowed to happen for N
seconds
#include <iostream>
int main()
{
  int e, r, n, t;
  std::cout << "Enter initial energy : ";
  std::cin >> e;
  std::cout << "Enter rate : ";
  std::cin >> r;
  std::cout << "Enter time : ";
  std::cin >> n;
  int i;
  for (i = 1; i <= n; i++)
  {
    if (i == 1)
      t = e;
    else
      t = t * r;
  }
  std::cout << "Energy generated : " << t << std::endl;
  system("pause");
  return 0;
}
Comments
Leave a comment