Write a program which take Energy (conservation)
value of m and c from user and return value of E along its unit.
E = mc^2
Input:
Output
value of m and c from user and return value of E along its unit.
E = mc^2
Input:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #include <iostream.h> #include <conio.h> int main() { cout << " Energy (conservation) Formula is E = m*c^2 \n"; float m, c, c2, E; cout << "Enter the value of m <mass>?\n"; cin >> m; cout << "Enter the value of c <speed of light>?\n"; cin >> c; c2 = c*c; E = m*c2; cout <<"\tE = "<< E << " kg m^2/s^2"<< endl; getch(); return 0; }// end main |
Output
Energy (conservation) Formula is E = m*c^2 Enter the value of m <mass>? 4.56 Enter the value of c <speed of light>? 3.456 E =54.4643 kg m^2/s^2
No comments:
Post a Comment