Calculate Reduced Mass in C language
First, we'll take input the values of masses of the first & second body, and then store them in the variables m1 and m2 respectively.
Then, we'll apply a condition, since mass can't be negative or less than zero.
After that, we'll apply the formula to calculate reduced mass.
Related:
Then, we'll apply a condition, since mass can't be negative or less than zero.
After that, we'll apply the formula to calculate reduced mass.
Calculate Reduced Mass in C language
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
void main() | |
{ | |
//declaration of variable | |
float m1, m2, rm; | |
//getting the value of mass of first body | |
printf("Enter the Value Of m1"); | |
scanf("%f",&m1); | |
//getting the value of mass of second body | |
printf("Enter the Value Of m2"); | |
scanf("%f",&m2); | |
if(m1>0 && m2>0) //applying condition since mass can't be negative | |
{ | |
// formula to calculate reduced mass | |
rm = ( (m1 * m2) / (m1+ m2) ); | |
printf("With the mass of first body %f and mass of second body %f, the value of reduced mass is %f kg", m1, m2, rm); | |
} | |
else | |
{ | |
printf("Mass can't be negative"); | |
} | |
} |
Related:
- Second Equation of Motion in C.
- C Program to check the number is positive negative or zero.
- How to Get Multiple Value from a Function in C.
- Calculator in C.
Comments
Post a Comment