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.

Recommended Answers

All 4 Replies

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;

}

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

Oops! I was looking at the attached file. Disregard my previous post.

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();
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.