Program to calculate Kinetic Energy and Potential Energy | C ++ Program to implement the above approach ; Function to calculate Kinetic Energy ; Stores the Kinetic Energy ; Function to calculate Potential Energy ; Stores the Potential Energy ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; float kineticEnergy ( float M , float V ) { float KineticEnergy ; KineticEnergy = 0.5 * M * V * V ; return KineticEnergy ; } float potentialEnergy ( float M , float H ) { float PotentialEnergy ; PotentialEnergy = M * 9.8 * H ; return PotentialEnergy ; } int main ( ) { float M = 5.5 , H = 23.5 , V = 10.5 ; cout << " Kinetic ▁ Energy ▁ = ▁ " << kineticEnergy ( M , V ) << endl ; cout << " Potential ▁ Energy ▁ = ▁ " << potentialEnergy ( M , H ) << endl ; return 0 ; }