0

Hey guys, I have just written C program that calculates the force of a body using F = ma but there is some sort of problem occuring , could you please help me fix the error.

Attachments
define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
#include <math.h>

int main(void) 

{

    double Force;
	int    mass;
	double a=9.81;
	
    printf("Enter the mass value: ");
	scanf("%lf", &mass);
	Force= m*a;

	printf("The Force of the body is : %f", Force);
	return 0;
}
4
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by chescarleta18
0

Your assignments did not match up.

#include <stdio.h>

#include <math.h>



int main(void)



{



    double Force;

        double    mass;

        double a=9.81;



    printf("Enter the mass value: ");

        scanf("%lf", &mass);

        Force= mass*a;



        printf("The Force of the body is : %5.2f\n", Force);

        return 0;

}
0

You have no declaration for m. Your Force calcuation needs to be Force = mass * a, not Force = m * a.

0

Hey guys, I have just written C program that calculates the force of a body using F = ma but there is some sort of problem occuring , could you please help me fix the error.

pls try this... it works 2 ur prob...

#include <stdio.h>
#include <math.h>
#define a 9.81

long float mass;

main()
{
double Force;
clrscr();

printf("Enter the mass value: ");

scanf("%lf", &mass);
Force= mass*a;

printf("The Force of the body is : %5.2f\n",Force);

getch();
}

Edited by pritaeas: Fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.