LA ke-2 untuk OSK kelas 2IA06

inilah listing program untuk LA OSK yg ke dua, silakan mencoba

#include <stdio.h>
#include <conio.h>
void main ()
{
char user;
int a,b,c;
do
{
clrscr ();
printf (“masukan 2 angka biner : “);
scanf (“%d %d”, &a,&b);
}
while (!(((a==1) || (a==0)) && ((b==1) || (b==0))));
printf (“pilih gerbang logika yg digunakan \n\t1.AND\n\t2.OR\n\t3.NAND\n\t4.NOR\n\t5.XOR\n\t6.XNOR\n\t7.XAND\n\n lalu operasi apa yg anda pilih : “);
fflush (stdin);
scanf(“%d”, &c);
switch (c)
{

case 1:
if ((a==1) && (b==1))
printf (“hasilnya = 1 “);
else
printf (“hasilnya = 0 “);
break;

case 2:
if ((a==0) && (b==0))
printf (“hasilnya = 0 “);
else
printf (“hasilnya = 1 “);
break;

case 3:
if ((a==1) && (b==1))
printf (“hasilnya = 0 “);
else
printf (“hasilnya = 1 “);
break;

case 4:
if ((a==0) && (b==0))
printf (“hasilnya = 1 “);
else
printf (“hasilnya = 0 “);
break;

case 5:
if ((a==0) && (b==0))
printf (“hasilnya = 0 “);
else if ((a==1) && (b==1))
printf (“hasilnya = 0 “);
else
printf (“hasilnya = 1 “);
break;

case 6:
if ((a==0) && (b==0))
printf (“hasilnya = 1 “);
else if ((a==1) && (a==1))
printf (“hasilnya = 1 “);
else
printf (“hasilnya = 0 “);
break;

case 7:
if ((a==1) && (b==1))
printf (“hasilnya = 0 “);
else
printf (“hasilnya = 1 “);
break;

}
getch ();
}

About ghesumar


Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: