Need Help with C Assignment to Compute a Pendulum's Motion?

  • Thread starter Shukie
  • Start date
  • Tags
    Assignment
In summary, the assignment involves computing the motion of a pendulum in C using the values provided in the given document and a step by step guide in Mathematica. To accomplish this, a loop needs to be created and a beginner's book on C and a C-compiler are recommended.
  • #1
Shukie
95
0

Homework Statement


The assignment is to compute the motion of a pendulum in C. The relevant information is listed in this document: http://home.orange.nl/~kuip3148/pendulum.c
It says which values to use for the variables, the relevant equations and has the value of NSTEPS, DT and PRINTEVERY. I have a step by step guide to solving this problem as well in Mathematica:

http://home.orange.nl/~kuip3148/Pendulum-assignment.nb

The Attempt at a Solution



The first thing I need to do is make a loop that runs NSTEPS times. Given my total lack of C knowledge, I run into a problem straight away. How can I make such a loop?
 
Last edited by a moderator:
Physics news on Phys.org
  • #2
I suggest you get a beginner's book to learning C to get the step by step basics. At the same time, you may want to install a c-compiler on your computer, such as Dev-C++, Borland, or Visual Studio express, they are all free and available from Bloodshed, Borland or Microsoft respectively.
Here is the help you asked for, and hope that helps.

int i;
... (define NSTEPS and other variables)

for(i=0;i<NSTEPS;i++)
{
... your code here
}
 
  • #3


I would recommend seeking help from a computer scientist or experienced programmer to assist with the technical aspects of writing code in C. They will be able to guide you through the process of creating a loop and implementing the relevant equations for the pendulum motion. Additionally, studying the step-by-step guide in Mathematica can help you understand the logic behind the code and how it can be translated into C. It may also be helpful to consult online resources or textbooks on C programming to gain a better understanding of the language. Remember to test your code and make any necessary adjustments to ensure accurate results. Good luck with your assignment!
 

FAQ: Need Help with C Assignment to Compute a Pendulum's Motion?

What is C programming language?

C is a high-level programming language developed in the 1970s. It is a powerful and efficient language commonly used for system programming, writing operating systems, and developing software applications.

What are the basic concepts of C programming?

The basic concepts of C programming include variables, data types, control structures, functions, arrays, and pointers. Understanding these concepts is crucial for writing efficient and effective programs in C.

How can I get help with my C programming assignment?

You can get help with your C programming assignment by seeking assistance from your professor or classmates, joining online forums and communities, or hiring a tutor. There are also many online resources and tutorials available to help you learn and understand C programming.

How do I write a C program?

To write a C program, you will need to follow a few basic steps such as defining your problem, designing the logic, writing the code, compiling and debugging, and finally testing the program. It is important to have a clear understanding of the problem and a well-designed plan before writing the code.

What are some common mistakes in C programming?

Some common mistakes in C programming include not declaring variables before using them, using incorrect data types, not terminating statements with a semicolon, and not checking for errors. It is also important to properly allocate and deallocate memory when using pointers to avoid memory leaks.

Back
Top