Progaram pemakaian beberapa Operator terhadap Relation dan Bit

Program :

/*pemakaian beberapa operator terhadap RELATIONAL dan BIT*/
#include<stdio.h>
#include<conio.h>
int main()
{
char i, j;
clrscr();
i=3;   /* 00000011 dalam biner */
j=4;   /* 00000100 dalam biner */
printf("i = %d\n",i);
printf("j = %d\n",j);
printf("i && j = %d\n",i&&j);   /*1:op Logika: true and true => true*/
printf("i & j = %d\n",i&j);         /*0: 00000000 dalam biner*/
printf("i || j = %d\n",i||j);         /*1: OR logika, true or true => true*/
printf("i | j = %d\n",i|j);            /*7: 00000111 biner*/
printf("i ^ j = %d\n",i^j);         /*7: 00000111 biner*/
printf("~i = %d\n",~i);              /*-4: 11111100 biner*/
getch();
}

Hasil Eksekusi :

Previous
Next Post »
Thanks for your comment