Thread: function

  1. #1

    Question function

    could somebody tell me what i'm doing wrong? i missed a class due to illness. my code is at the bottom
    Library functions allowed: printf, scanf

    Write a program that will compute and display the date of Easter Sunday
    for a given year entered by the user.

    Your program begins by displaying the following on the screen:

    This program calculates the Easter Sunday for a given year.
    Please type a year between 500 and 4000 inclusive. (0 to quit)

    The user will type a year, such as 1997. Your program will get the data
    typed by the user, and save it in the variable called YEAR.

    If the user has typed 0, then your program stops.

    If the user has typed an invalid year, display the message:
    The year is not valid.

    Then the program returns to the beginning again.

    If the user has typed a valid year, then call the calculatex function,
    which will calculate the value of x. The main function must NOT do any
    calculation using the formulas.

    The formula for calculating the Easter Sunday date is:

    X = 22 + A + B, where

    A = remainder of ((19 x C) + 24) / 30
    B = remainder of (( 2 x D) + (4 x E) + (6 x A) + 5) / 7
    C = remainder of YEAR / 19
    D = remainder of YEAR / 4
    E = remainder of YEAR / 7

    The calculatex function will return the value of x to the main function.

    The main function will save the value of x in a variable called "dayx".
    The main function then checks the value of dayx as follows:
    If dayx is 31 or less, then Easter Sunday is in March, on dayx. For
    example, if dayx = 11, then Easter Sunday is on March 11.

    If the dayx is greater than 31, Easter will be in April. First subtract 31
    from dayx. For example, if dayx = 33, subtract 31 from dayx, and dayx
    becomes 2. Easter Sunday will be on April 2.

    Your program should display the result as follows:

    Easter Sunday of ... is on ....

    For example, if you run your program and you type 1997, your program
    should display:

    Easter Sunday of 1997 is on March 30.

    After displaying the Easter Sunday date, the program returns to the
    beginning again.

    Check your program with the following years, and other conditions.

    Year Easter Sunday
    1997 March 30
    500 April 15
    4000 April 1

    The following gives you some hints on how your program may look like.
    The ... are missing parts for you to fill in to complete the program.
    The ... can be one or more lines of C statements.

    #include <stdio.h>
    ... calculatex (...); /* function prototype */
    int main (void)
    int dayx;
    dayx = calculatex (YEAR); /* call the calculatex function */
    if (dayx > 31)

    ... calculatex (...) /* function definition */
    int x;
    return x;

    #include <stdio.h>

    int calculatex(int y, int x);

    int main(void)
    int dayx, year;


    printf("this program calculates the easter sunday for a given year./n");

    printf("Please type a year between 500 and 4000 inclusive. (0 to quit./n");

    scanf("%d", &year):


    printf("Invalid number./n");



    printf("Easter Sunday of %d is on April %d.\n", year, dayx);

    printf("Easter Sunday of %d is on March %d.\n", year, dayx);



    int calculatex(int y, int x)
    int a, b, c, d, e, x;


    return x;

  2. #2
    Registered User
    Join Date
    Mar 2002
    umm all looks pretty alright to me except you have your end of line chars the wrong way, it should be \n not /n. what exactly is the problem with the program?

  3. #3
    i'm getting missing arguments on line 32


  4. #4
    several stupid mistakes, figured it out thanx

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  3. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  4. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  5. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 06:44 PM