Monday, 8 December 2014

C Program to observe Logical operations behaviour

Program for Logical operations checking
#include<stdio.h>
#include<stdlib.h>
main()
{
int a=-5,b=3,c=0,d;
d=(a==b)&&(b==c)&&(c==a);
printf("%d\n",d);
d=(a=b)||(b=c)||(c=a);
printf("%d\n",d);
d=(a=b)&&(b=c)||(c=a);
printf("%d\n",d);
d=(a=b)||(b=c)&&(c=a);
printf("%d\n",d);
}
OutPut:
madan@madan-Lenovo-G570:~/madan$ cc ex41.c
madan@madan-Lenovo-G570:~/madan$ ./a.out
0
1
1
0