Thread: re pointers

  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    2

    re pointers

    hello
    this is niharika
    i need help with an assignment.
    the question is

    Implement a function that converts a day of the year (a number between 1 and 366) into a month and day.

    int dateSplit(int dayOfYear, int year, int *day, int *month);
    The function should return 1 if the conversion is sucessful and 0 if dayOfYear and/or year are not valid.

    A sample program testing the function, along with its output, is given below.

    Your test program and your solution should be placed in separate files. Submit only the file dateSplit.c containing your solution function.

    Code:

    Code:
    Sample Test Program 
    #include <stdio.h>
    
    int dateSplit(int dayOfYear, int year, int *day, int *month);
    
    void testDateSplit(int dayOfYear, int year)
    {
      int day, month;
    
      if (dateSplit (dayOfYear, year, &day, &month))
        printf ("&#37;d,%d => %d,%d\n", dayOfYear, year, day, month);
      else
        printf ("%d,%d => invalid\n", dayOfYear, year);
    }
    
    int main (void)
    {
      testDateSplit (100, 2007);
      testDateSplit (100, 2008);
      testDateSplit (1, 2007);
      testDateSplit (1, 2008);
      testDateSplit (365, 2007);
      testDateSplit (366, 2007);
      testDateSplit (366, 2008);
      testDateSplit (-1, -1);
    
      return 0;
    }
    Sample Output
    100,2007 => 10,4
    100,2008 => 9,4
    1,2007 => 1,1
    1,2008 => 1,1
    365,2007 => 31,12
    366,2007 => invalid
    366,2008 => 31,12
    -1,-1 => invalid
    [/quote]
    here i need to write the main funtion for this program statement as the test program is already given. please help me. i nee the code. it is urgent
    Last edited by Salem; 11-03-2008 at 12:40 PM. Reason: Snip email address - you posted it here, you read it here

  2. #2
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Ask a specific question about what you're having trouble with.
    Nobody here is going to write the whole thing for you.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  3. #3
    Registered User
    Join Date
    Sep 2008
    Location
    California
    Posts
    19
    I wouldn't post your email address on a public forum. It's going to get destroyed by a ton of spam bots soon.

    Secondly, yeah, try to write the code on your own. The people here are very helpful, but they aren't going to do your work for you. Taking someone else's work, especially without understanding it, is cheating.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    More of the same - http://cboard.cprogramming.com/showthread.php?t=108828
    This is closed.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using pointers to pointers
    By steve1_rm in forum C Programming
    Replies: 18
    Last Post: 05-29-2008, 05:59 AM
  2. Replies: 4
    Last Post: 12-10-2006, 07:08 PM
  3. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  4. Staticly Bound Member Function Pointers
    By Polymorphic OOP in forum C++ Programming
    Replies: 29
    Last Post: 11-28-2002, 01:18 PM