LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-10-2005, 01:42 PM   #1
MoeedK
LQ Newbie
 
Registered: Aug 2005
Location: Toronto
Posts: 2

Rep: Reputation: 0
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.
 
Old 08-10-2005, 02:04 PM   #2
lowpro2k3
Member
 
Registered: Oct 2003
Location: Canada
Distribution: Slackware
Posts: 340

Rep: Reputation: 30
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.
 
Old 08-10-2005, 02:08 PM   #3
MoeedK
LQ Newbie
 
Registered: Aug 2005
Location: Toronto
Posts: 2

Original Poster
Rep: Reputation: 0
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.
 
Old 08-10-2005, 02:36 PM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,632
Blog Entries: 4

Rep: Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931
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! )
 
Old 08-10-2005, 07:41 PM   #5
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
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.

Last edited by Hko; 08-10-2005 at 07:43 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Hi guys! einnor LinuxQuestions.org Member Intro 5 01-28-2005 12:32 AM
Hello, fairly new Linux user, looking forward to learning from you guys kenscottiii LinuxQuestions.org Member Intro 3 11-28-2004 05:03 AM
How do i get started guys?? teachmelinux Linux - Newbie 6 08-14-2004 02:40 AM
Did you guys learn C the way I'm learning C? psiakr3w Programming 7 08-01-2004 04:12 PM
What Now Guys! dannyflounders Slackware 10 07-29-2003 08:59 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration