Thread: Total newbie to programming C! Need help...

  1. #1
    Registered User
    Join Date
    Nov 2005

    Total newbie to programming C! Need help...


    For reference, I am using ANSI C.

    I'm a complete noob when it comes to C and pretty much all programming, so p
    lease bare with me! I'm sure this will be extremely easy to you guys, but I'
    m pretty clueless.

    I have 2 questions.

    I am currently writing a program to use the Newton Raphson method to find a
    root to an equation. The equation is a non variable. All the user has to do
    is enter the starting value.

    Basically, for those unfamiliar with this mathematical method, you enter a v
    alue for x, and the equation works out a new value for x. You keep doing thi
    s until your value of x becomes pretty much the same.

    I want my program to keep doing the equation until the difference between th
    e two x values is less than 0.001. I'm pretty sure I have to use a do while
    loop, but I have no idea how to go about it. Any help would be extremely app

    Secondly, this is probably really simple, but I just don't know how to begin
    . I am writing a program where the user enters a date in the following fashi

    01 05

    ie - the above date would be the first of May, or:

    06 02

    Would be the 6th of february. Then, the user enters a second date in the sam
    e manner. It is then calculated how many days are between the two dates the
    user enters, and it is displayed.

    Feb can be taken to have 28 days, so the leap year isn't an issue. But I rea
    lly don't know what to do with this. Help would, again, be massively appreci

    Thanks for taking your time to read this, and any help you may offer!

  2. #2
    Bond sunnypalsingh's Avatar
    Join Date
    Oct 2005
    Solution to your first problem...modify it according to your needs

    Note:Try searching net before will easily get answers of such standard questions.

  3. #3
    Registered User
    Join Date
    Mar 2005
    Mountaintop, Pa
    This calculates the number of days between two dates. I haven't thoroughly tested this function. So, it's your responsibility to test it.

    Have fun

    #include <stdio.h>
    unsigned long JulianDaysCalc(int iMonth, int iDay, int iYear)
        //Calculation of serial Julian date
        int iTemp;
        int iYearCalc;
        int iMonthCalc;
        unsigned long ulSerialJulianDate;
        iTemp = (14 - iMonth)/12;
        iYearCalc = iYear + 4800 - iTemp;
        iMonthCalc =  iMonth+ (12*iTemp) - 3;
        ulSerialJulianDate = iDay + (((153*iMonthCalc) +2)/5) + (365*iYearCalc)
            + (iYearCalc/4) - (iYearCalc/100)+ (iYearCalc/400) - 32045;
        return ulSerialJulianDate;
    int main(void)
        unsigned long ulJdate1, ulJdate2;
        ulJdate1 = JulianDaysCalc(11, 22, 2005);
        ulJdate2 = JulianDaysCalc(11, 20, 2005);
        printf(" Date diff %ld\n", (ulJdate1 - ulJdate2));
        return 0;

  4. #4
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Out of scope
    You should add something that formats user inputs for different date formats.
    Sent from my iPadŽ

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with basic calculation program.
    By StateofMind in forum C Programming
    Replies: 18
    Last Post: 03-06-2009, 01:44 AM
  2. Help with day of the week program
    By Punkakitty in forum C++ Programming
    Replies: 10
    Last Post: 01-14-2009, 06:55 PM
  3. Replies: 8
    Last Post: 11-03-2008, 09:48 PM
  4. The Timing is incorret
    By Drew in forum C++ Programming
    Replies: 5
    Last Post: 08-28-2003, 04:57 PM
  5. Replies: 4
    Last Post: 04-22-2003, 12:52 PM