lvalue required as left operand of assignment (??)

This is a discussion on lvalue required as left operand of assignment (??) within the C Programming forums, part of the General Programming Boards category; I'm doing an example question from my C book.. a leap year is any year divisible by 4, unless it's ...

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    8

    Unhappy lvalue required as left operand of assignment (??)

    I'm doing an example question from my C book.. a leap year is any year divisible by 4, unless it's divisible by 100 but not 400. this is what I came up with, but it won't compile. it says "leap.c:14: error: lvalue required as left operand of assignment"..

    Code:
    #include <stdio.h>
    
    char line[10];
    int input;
    
    main()
    {
            printf("Is this year a leap year?\nInput year: ");
            fgets(line, sizeof(line), stdin);
            sscanf(line, "%d", &input);
    
            if (input%4 == 0)
            {
                    if ((input%100 == 0) && (input%400 =! 0))
                            printf("Is not a leap year\n");
                    else printf("Is a leap year\n");
            }
            else printf("Is not a leap year\n");
    
            return (0);
    }
    anyone know what the deal is? thanks for any help!!

  2. #2
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    Code:
    input%400 =! 0
    Should be
    Code:
    input%400 != 0
    Also, change
    Code:
    main()
    to:
    Code:
    int main(void)

  3. #3
    Registered User
    Join Date
    Nov 2009
    Posts
    8
    =) thankyou so so much! just brightened my evening...

  4. #4
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    Your welcome!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 09:33 AM
  2. Binary Tree Revisited: Near Completion
    By Nakeerb in forum C++ Programming
    Replies: 13
    Last Post: 01-22-2003, 07:23 AM
  3. Templated Binary Tree... dear god...
    By Nakeerb in forum C++ Programming
    Replies: 15
    Last Post: 01-17-2003, 01:24 AM
  4. Release Configuration Problems
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2002, 04:54 AM
  5. Please help me
    By teedee46 in forum C++ Programming
    Replies: 9
    Last Post: 05-06-2002, 11:28 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21