Check whether given no is odd or even without using arithmatic operator

//Check the given number is odd or even without using modulo and devision
#include<stdio.h>
void main()
{
    int no;
    clrscr();
    printf("Enter a no: ");
    scanf("%d", &no);
    if(no&1)
    printf("Given number is Odd number");
    else
    printf("Given numbre is even number");
    getch();
}
Click Here to Download

// Check the given number is odd or even without using modulo operator
#include<stdio.h>
#include<conio.h>
void main()
{
    int no;
    clrscr();
    printf("Enter the no : ");
    scanf("%d",&no);

    if((no/2)*2==no)
        printf("Given number is even number ");
    else
        printf("Given number is odd number ");
    getch();
}
Click Here to Download

 

No comments:

Post a Comment