Thread: Noob .help

  1. #1
    Registered User IG SIV0IVIAIV's Avatar
    Join Date
    Jul 2009
    Location
    upstate NY
    Posts
    1

    Wink Noob .help

    So basically i wanted to get into learning C programming, and i got the book C Programming second edition for the Absolute beginner i just started reading and doing the given challenges in the book until i got stumped on probably one of the easiest one. If you could help it'll be much apprieciated. basically the questions ask, Given a = 5, b = 1, x =10 ,and y =5, create a program that out puts the result of the formula f = (a - b)*(x - y) using a single printf() function? i don't expect anyone to write the code even tho i'm sure its easy i just need some points up to this point i have most basics down. this being simple math is easy to do with just a pen and paper but on the computer its different. please help

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    A "challenge" is something you take on when you have some proficiency at something. Obviously, you still haven't gotten down the basics yet, so I'd suggest doing that before you proceed any further.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  3. #3
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Sebastiani View Post
    A "challenge" is something you take on when you have some proficiency at something. Obviously, you still haven't gotten down the basics yet, so I'd suggest doing that before you proceed any further.
    What Sebastiani is trying to say here is that he would like to see some code you have tried please so we can understand better what is going on in your head.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by IG SIV0IVIAIV View Post
    this being simple math is easy to do with just a pen and paper but on the computer its different. please help
    And of course this sentence here is amazingly false. The math on the computer, funnily enough, is exactly the same as the math you do on paper.

  5. #5
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    Something like this?
    Code:
    printf("f = %d\n", (a - b) * (x - y));

  6. #6
    Registered User Cooloorful's Avatar
    Join Date
    Feb 2009
    Posts
    59
    You could make it interesting and try to solve for an unknown. But be that as it may, why not just simply make an explicit function?

    Code:
    double f(double x)
    {
      // do stuff here.
    }
    Then you can simply call f(x) as you please.
    wipe on -
    A slap on the hand is better than a slap on the face. A tragic lesson learned far too late in life.
    - wipe off

  7. #7
    One Level Below Beginner
    Join Date
    Jul 2009
    Location
    Corner of Nowhere and Yonder
    Posts
    19
    I'm sorry for answering a week old post....

    But I'm sure if you re-read the chapter where the challenge was in, you'll find the answer you are looking for.....

    Also, don't forget to go back and study how int is used....

    Here's a bit of a hint: the code will have 10 lines (without white spaces, but with the last newline)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. quick noob question
    By thanatos1 in forum C# Programming
    Replies: 2
    Last Post: 06-17-2009, 08:28 PM
  2. noob needs help!!!!:(
    By tykenfitz in forum C Programming
    Replies: 1
    Last Post: 07-10-2005, 08:49 AM
  3. Just a little request from a noob...
    By Lee134 in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 03-18-2005, 05:45 AM
  4. simple noob question: HWND, HDC etc.
    By freedik in forum Windows Programming
    Replies: 12
    Last Post: 08-19-2003, 03:59 AM
  5. noob: compiling error... plz help!
    By chosii in forum C Programming
    Replies: 2
    Last Post: 05-10-2002, 05:53 AM