21. WAP to understand logical operators.
#include<stdio.h>
void
main()
{
/*
PART 1
int i=10,j=20,k;
k=i&&j;
printf("k = %d\n",k);
*/
/*
PART 2
int i=100,j=200,k;
k=i&&j;
printf("k = %d\n",k);
*/
/*
PART 3
int i=0,j=10,k;
k=i&&j;
printf("k = %d\n",k);
k=i||j;
printf("k = %d\n",k);
k=!i;
printf("k = %d\n",k);
*/
/*
PART 4
int i=10;
printf("i=%d\n",i);
!i;
printf("i=%d\n",i);
*/
/*
PART 5
int i=0,j=20,k;
k=1&&(j=200);
printf("i = %d j = %d k =
%d\n",i,j,k);
*/
/*
PART 6
int i=0,j=20,k;
k=1||(j=200);
printf("i = %d j = %d k =
%d\n",i,j,k);
*/
/*
PART 7
int i=10,j=20,k=30,l=40,m=50,r;
r=i&&(j=200)||(k=300)&&(l=400)||(m=500);
printf("i = %d j = %d k = %d l =
%d m = %d r = %d\n",i,j,k,l,m,r);
*/
//
PART 8
int i=10,j=20,k=30,l=40,m=50,r;
r=i||(j=200)&&(k=300)||(l=400)&&(m=500);
printf("i = %d j = %d k = %d l =
%d m = %d r = %d\n",i,j,k,l,m,r);
}
Comments
Post a Comment