Thread: program which has day of the year and month day

  1. #1
    Registered User
    Join Date
    Aug 2021
    Posts
    1

    Lightbulb program which has day of the year and month day

    Hi All,

    I'm a beginner in C.
    When I read a code about "program which has day of the year and month day" in reference. I'm confuse in the code(in red color). this is an argument? or condition?

    Code:
    void month_day(int year, int yearday)
    {
    int i, leap;
    
    
    leap = year % 4 == 0 && year % 100 != 0 || year % 400 == 0;
    
    
    for (i = 1; yearday > daytab[leap][i]; i++)
    yearday -= daytab[leap][i];
    
    
    printf("Month: %d, Day: %d\n", i, yearday);
    
    
    }

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    It's a boolean expression.

    Here's the same thing expanded.
    Code:
    if ( year % 4 == 0 && year % 100 != 0 || year % 400 == 0 ) {
      leap = 1;
    } else {
      leap = 0;
    }
    A boolean expression evaluates to false(0) or true(1)
    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. Need help Creating C program day, month, year
    By Mat8854 in forum C Programming
    Replies: 3
    Last Post: 09-06-2012, 06:12 PM
  2. Help with Day Month Year Program..due by 12
    By jgassen15 in forum C Programming
    Replies: 1
    Last Post: 12-06-2007, 11:21 PM
  3. Year, month and day
    By Newbie999 in forum C Programming
    Replies: 15
    Last Post: 12-01-2006, 10:17 AM
  4. getting the next day's day, month, year etc
    By underthesun in forum C Programming
    Replies: 3
    Last Post: 02-17-2005, 07:43 AM
  5. need current day, month, year
    By ihatejava in forum C++ Programming
    Replies: 2
    Last Post: 10-19-2002, 11:41 AM

Tags for this Thread