Professional Documents
Culture Documents
Lab 3
Lab 3
Algorithm :
1.Start
2.Declare and initialize the variables:
mass (m) of the particle (in kilograms)
height (h) (in meters)
velocity (v) of the particle (in meters per second)
gravitational acceleration (g) (usually 9.81 m/s^2 on Earth)
mechanical energy (E)
3.Prompt the user to input the values of mass, height, and velocity.
4.Calculate the mechanical energy (E) using the formula E = m * g * h + 0.5
* m * v * v.
5.Display the calculated mechanical energy.
6.End
Code :
#include <stdio.h>
int main ()
printf("Enter the mass of the particle (kg): ");// Prompt the user for input
scanf("%lf", &mass);
scanf("%lf", &height);
scanf("%lf", &velocity);
LAB3
return 0;
Output :