
II-60 Programming Concepts
Examples on logical operators
9. Program on simple logical problem
void main()
{
int a=4,b=2,m,n,o;
clrscr();
m=a&&b;
n=a||b;
o=a==b;
printf("\n%d",m);
printf("\n%d",n);
printf("\n%d",o);
getche();
}
OUTPUT:
1
1
0
Examples on relational and logical operators
10. Program on simple logical problem
void main()
{
int x=2,y=0,z=8,p;
clrscr();
z=x>y&&y;
p=x||z;
printf("\n%d\n%d",z,p);
getch();
}
OUTPUT:
0
1
M03_ITL-ESL4791_02_SE_C03.indd 60 12/22/2012 5:00:08 PM