CrazyEngineers
  • #include
    #include
    
    int main()
    {
      int no;
      char ch[0]="Even";
      char ch[1]="odd";
      printf("Enter a no. \t");
      scanf("%d",&no);
    
      printf("\n The no. is %s",ch[no%2]);
    
    return (0);
    }
    
    // in above c code using % operator and array we can find the no. is even or odd also we can perform it by using bitwise AND operato (&) and AND operator (&&).................
    I gave u the hint can anybody is able to write 2nd program ...😉😀//

    o/p--> Enter a no. 7
    The no. is odd

    Enter a no. 4
    The no. is Even
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Anoop Kumar

    MemberSep 19, 2013

    Good program but in wrong category.
    You should post computer and IT related stuffs at following section:
    #-Link-Snipped-#
    Are you sure? This action cannot be undone.
    Cancel
  • nareshkumar6539

    MemberSep 19, 2013

    Gaurav v. Deshmukh
    #include<stdio.h>
    #include<conio.h>
    
    int main()
    {
      int no;
      char ch[0]="Even";
      char ch[1]="odd";
      printf("Enter a no. \t");
      scanf("%d",&no);
    
      printf("\n The no. is %s",ch[no%2]);
    
    return (0);
    }
    
    // in above c code using % operator and array we can find the no. is even or odd also we can perform it by using bitwise AND operato (&) and AND operator (&&).................
    I gave u the hint can anybody is able to write 2nd program ...😉😀//

    o/p--> Enter a no. 7
    The no. is odd

    Enter a no. 4
    The no. is Even
    When we use logical and or bit wise first it will convert number into binary format then it will perform the operation.
    When we perform Logical and or Bitwise and operation with NUMBER&&1 it will give
    one means it is ODD number it will give 0 means EVEN number.
    (NUMBER&&1)?"ODD":"EVEN" or (NUMBER&1)?"ODD":"EVEN"
    Are you sure? This action cannot be undone.
    Cancel
  • rahul69

    MemberSep 20, 2013

    nareshkumar6539
    When we use logical and or bit wise first it will convert number into binary format then it will perform the operation.
    When we perform Logical and or Bitwise and operation with NUMBER&&1 it will give
    one means it is ODD number it will give 0 means EVEN number.
    (NUMBER&&1)?"ODD":"EVEN" or (NUMBER&1)?"ODD":"EVEN"
    Logical And will not work! because logical And can only check if the number is non zero, to check even odd, you will have to use bitwise And ie '&'
    Are you sure? This action cannot be undone.
    Cancel
  • Vinut47

    MemberJun 24, 2016

    7 easy ways to find whether a number id odd/even.
    #-Link-Snipped-#
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register