Thread: Logical Operators

  1. #1
    Registered User
    Join Date
    Aug 2012
    Posts
    2

    Logical Operators

    hi.. I'm just starting to learn C language... pls help me with this code. When I input either 5 or 6 or 7, it doesnt print the right output... could some help me .pls

    Code:
    #include <stdio.h>
    void main()
    {
        int a;
    
    
        printf("enter an integer from 1 to 10: \n");
        scanf("%d", a);
    
    
        if (a > 4 && a < 8)
        {
            printf("The number is either 5, 6 or 7");
        }
        else if (a <= 2 || a >= 9 )
        {
            printf("The number is either 1,2,9 or 10");
        }
        else
        {
            printf("The number is 3, 4, or 8");
        }
    }

  2. #2
    Registered User
    Join Date
    Aug 2012
    Posts
    41
    Code:
    scanf("%d",&a);
    This will solve your problem.

  3. #3
    Registered User
    Join Date
    Aug 2012
    Posts
    2
    Thank u. its solved.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Logical Operators in C++
    By Flecto in forum C++ Programming
    Replies: 4
    Last Post: 05-15-2009, 07:17 AM
  2. logical operators on objects?
    By nocturna_gr in forum C++ Programming
    Replies: 5
    Last Post: 12-20-2007, 06:59 AM
  3. logical operators
    By Marlon in forum C++ Programming
    Replies: 5
    Last Post: 07-13-2005, 02:55 AM
  4. Logical Operators
    By E i F x 65 in forum C++ Programming
    Replies: 6
    Last Post: 01-24-2002, 08:45 AM
  5. logical operators
    By sballew in forum C Programming
    Replies: 4
    Last Post: 09-04-2001, 06:24 PM