Like Tree1Likes
  • 1 Post By sana.iitkgp

Logical Operators

This is a discussion on Logical Operators within the C Programming forums, part of the General Programming Boards category; hi.. I'm just starting to learn C language... pls help me with this code. When I input either 5 or ...

  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.
    Click_here likes this.

  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, 08: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, 03: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, 07:24 PM

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