forked from casafurix/c-programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbitwise.c
More file actions
31 lines (31 loc) · 783 Bytes
/
bitwise.c
File metadata and controls
31 lines (31 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stdio.h>
#include <stdlib.h>
#define BITS sizeof(int) * 8
int isPositive(int n)
{
return !(n&(1<<(BITS-1))|(!n));
}
int main()
{
int n;
printf("Enter a first number : ");
scanf("%d",&n);
int m;
printf("Enter a second number : ");
scanf("%d",&m);
if((n^m)==0)
printf("Equal\n");
else
printf("Unequal\n");
if((n&1)==1)
printf("%d is Odd\n",n);
else
printf("%d is Even\n",n);
if ((m&1)==1)
printf("%d is Odd\n",m);
else
printf("%d is Even\n",m);
isPositive(n)? printf("%d is Positive number\n",n):(n)? printf("%d is Negative number\n",n): printf("Zero\n");
isPositive(m)? printf("%d is Positive number\n",m):(m)? printf("%d is Negative number\n",m): printf("Zero\n");
return 0;
}