LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Hi guys, need a little help!!!!!Just started learning C (https://www.linuxquestions.org/questions/programming-9/hi-guys-need-a-little-help-just-started-learning-c-351906/)

MoeedK 08-10-2005 01:42 PM

Hi guys, need a little help!!!!!Just started learning C
 
I just started learning C. Its pretty good sofar how ever I have an assingment coming up shortly.



I do not have any prior programming experience. I am up to arrays...as my learning is going on.

Here is the main problem.
I have to write a program that takes in a sin and cos equations and illustrates the amplitutes, phase shift, the period of the function, range and horizontal shoft.

My question is, where do I start, how do I analyze the equation, second.... will be really hard to make the graphs ? or am I thinking too far ? I only have 6 to 7 weeks left and its either this or a trivia game which looks too easy, I want a challenge but I donot want to choose something that I cannot do in the given time.

lowpro2k3 08-10-2005 02:04 PM

For getting started, I find its often easiest to forget programming for a little bit, and work out the logic with a pencil and paper. Once you get it on paper you'll be in a better position to write great code.

MoeedK 08-10-2005 02:08 PM

well the thing is I can solve the equation, I just need a hint on how to get it from user and how to store it. I was thinking of storing it in a string and then take the values.

basically:
here is wat Ihave so far: y = aSin(bx+c)+d
I just need to know a way to get a b c d


I am not sure if take it in as a string is cheating.

sundialsvcs 08-10-2005 02:36 PM

Your best bet would be to ask your instructor on this one. Functions like fscanf() can be used to take a string, parse it into numbers or strings and so-on. Functions like fprintf() perform a similar task for output.

As lowpro2k3 suggested, work out the entire problem on-paper. That includes not only "solving the equation," but working out step-by-step "what you want the computer to do, start-to-finish." This in itself is not a trivial exercise!

Once you work that out, show it to your instructor and ask for guidance. After all, once you have the what worked-out thoroughly, all that C stuff is "merely the how." Your instructor should be happy to help ... and should also be delighted at your progress. Just seek help timely, and be prepared. Have your ducks in a row.

And I assure you, when the due-date comes, you might be the only student in the room who does not have a glum look on your face. Even if you did not complete the full assignment in-time, if your what (your "algorithm") is entirely correct, you have made a very substantial advance toward completing the entire assignment and are probably much farther along than the others. Most people, who know C perhaps a little more, "plunge right into the 'how' without considering the 'what.'"

(I teach in colleges. I know! :D )

Hko 08-10-2005 07:41 PM

Quote:

I have to write a program that takes in a sin and cos equations and illustrates the amplitutes, phase shift, the period of the function, range and horizontal shoft.

My question is, where do I start, how do I analyze the equation, second.... will be really hard to make the graphs ? or am I thinking too far ? I only have 6 to 7 weeks left and its either this or a trivia game which looks too easy, I want a challenge but I donot want to choose something that I cannot do in the given time.
To analyse the equation, you'll have to deal with precedence of the operators. Storing them in a tree-structure will help. Subjects to search for, read and learn about (more or less in this order):
  • Pointers, struct/s and union's
  • Binary trees and recursion
  • Recursive descent and expression trees

You'll need to choose and learn about some graphic library ("widget API") to use to draw the graphs. For plain C, the GTK-library or the SDL-library the are the most logical choices IMHO.

SDL is more about game programming, while GTK is more aimed at all kinds of dekstop applications. I'd suggest GTK for this.

Probably a hard job to do in 6, 7 weeks (fulltime?) if still at about 30% percent of learning the C language itself. May be do-able though, depending on your talent, and whether programming is fun to you.


All times are GMT -5. The time now is 03:03 PM.