Home C Language Basic C Programs Newton’s 3rd law

Newton’s 3rd law

Write a C Program to Simulate 3rd Law at Motion.

#include<stdio.h>

int main()

{

   float m,a,f;

   printf(“Enter mass (in kgs):”);

   scanf(“%f”,&m);

   printf(“Enter acceleration(m/s^2):”);

   scanf(“%f”,&a);

   if(m<0||a<0)

   {

      printf(“Please enter positive values\n”);

      return 0;

   }

   f=m*a;

   printf(“Force=%.2f newtons\n”,f);

   return 0;

}

Output :

Enter mass (in kgs):95

Enter acceleration (m/s^2):52

Force=4940.00 newtons