Thread: problem in school

  1. #1
    Unregistered
    Guest

    problem in school

    this is an assignment for my class and it is supposed to be a calendar but i cant figure out how th make the spaces for the day that the user chooses. any help would be appreciated


    include <stdio.h>

    main()

    {
    int i, n, day;
    printf("enter number of days in the month:");
    scanf("%d",&n);
    printf("Enter starting day of the week (1=Sun, 7=Sat):");
    scanf("%d",&day);
    for (i=1; i <= n ; i++)
    {
    if (i==(9-day) ||i==(16-day) || i==(23-day) || i==(30-day))
    {
    printf("\n");
    //day++;
    }
    printf("%3d", i);
    }
    return 0 ;

  2. #2
    Unregistered
    Guest

    a little addition

    the book shows it like this:
    Enter days in the month: 31
    enter starting day(1=Sun, 7+Sat): 3
    1 2 3 4 5
    6 7 8 9 10 11
    ...

  3. #3
    The Artful Lurker Deckard's Avatar
    Join Date
    Jan 2002
    Posts
    633
    Try adding this right after the scanf() to get the starting day of the month:

    Code:
    for ( i=0; i<(day-1); i++ )
      printf("   "); /* That's three spaces */
    Also, the code you posted won't compile. You're missing the '#' before the preprocessor include, and a '}' to close out main().

    While you're at it, declare main() to return type int.
    Last edited by Deckard; 01-23-2002 at 07:50 PM.
    Jason Deckard

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM
  2. array problem?
    By ssjnamek in forum C Programming
    Replies: 14
    Last Post: 02-08-2006, 06:03 PM
  3. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM
  4. binary tree problem - help needed
    By sanju in forum C Programming
    Replies: 4
    Last Post: 10-16-2002, 05:18 AM
  5. Simple problem for you guys - school proj
    By ryancsutton in forum C++ Programming
    Replies: 7
    Last Post: 10-01-2002, 03:06 PM