Thread: C program to check leap year - student question willie evangelista

  1. #1
    Registered User
    Join Date
    Oct 2014
    Location
    General Trias, Cavite, Philippines
    Posts
    1

    C program to check leap year - student question willie evangelista

    Question:
    How do i tweak the output of this code:
    ~let say i type in 2012 and the output should be February 29, 2014 Wednesday is a leap year (same thing with the other leap year)
    ~ i type in 2013 and the output should be 2013 is not a leap year.

    Thanks in advance.
    ----------------------------------------current code---------------------------
    Code:
    include <stdio.h>int main()
    {
    int year;
    printf("Enter a year to check if it is a leap year\n");
    scanf("%d", &year);
    if ( year%400 == 0)
    printf("%d is a leap year.\n", year);
    else if ( year%100 == 0)
    printf("%d is not a leap year.\n", year);
    else if ( year%4 == 0 )
    printf("%d is a leap year.\n", year);
    else
    printf("%d is not a leap year.\n", year);
    return 0;
    
    }
    Attached Images Attached Images C program to check leap year - student question willie evangelista-leap-year-c-png 

  2. #2
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    It sounds like you just want to add a simple print statement (or even just edit an existing one).

    Did you write this yourself? It should be quite easy to add.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Of course they didn't write it themselves, they forgot to change the image to show where they got the program from.
    C program to check leap year | Programming Simplified

    And of course, it's cross-posted as well.
    http://stackoverflow.com/questions/2...heck-leap-year
    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. Leap year program error
    By nsriv in forum C Programming
    Replies: 15
    Last Post: 12-17-2012, 07:18 AM
  2. leap year program
    By camel-man in forum C Programming
    Replies: 5
    Last Post: 05-23-2011, 07:50 PM
  3. Program showing if a year its leap year or not.
    By Cyberman86 in forum C++ Programming
    Replies: 5
    Last Post: 09-12-2008, 08:00 AM
  4. Help with leap year program.
    By IxTanGxI in forum C Programming
    Replies: 8
    Last Post: 02-20-2006, 08:49 PM

Tags for this Thread