Answer to Question #294199 in C++ for mahi

Question #294199



Write an algorithm to find the energy


produced at every second if the


reaction is allowed to happen for N


seconds



1
Expert's answer
2022-02-05T10:31:13-0500
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog