-
Notifications
You must be signed in to change notification settings - Fork 0
/
OBJECT6.CPP
73 lines (73 loc) · 1.28 KB
/
OBJECT6.CPP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main(void)
{
int a,b,result,choice,test;
do{
clrscr();
printf("\n\t\t****LOGIC GATE****\t\t\t");
printf("\n\nEnter Two Numbers Note: Number should be are 0 & 1.");
printf("\n\t\tEnter first number:");
scanf("\n\t\t%d",&a);
printf("\n\t\tEnter second number:");
scanf("\n\t\t%d",&b);
if( (a==0 || a==1) && (b==0 || b==1) ){
printf("\nWhich Gate You want to check between above two input");
printf("\n\t\tOR-1");
printf("\n\t\tAND-2");
printf("\n\t\tXOR-3");
printf("\n\t\tEXIT-0");
printf("\n\t\tENTER YOUR CHOICE NUMBER:");
scanf("%d",&choice);
switch (choice){
case 0:
exit(0);
break;
case 1:
//clrscr();
printf("\n\t\tOR\t\t");
if (a || b)
{
printf("\nResult=1" );
break;
getch();
}
else{
printf("\nResult= 0");
break;
}
case 2:
//clrscr();
printf("\n\t\tAND\t\t");
if(a && b){
printf("\nResult= 1");
getch();
break;
}
else{
printf("\nResult= 0");
break;
}
case 3:
printf("\n\tXOR");
if((a ==0 && b==0)||(a==1 && b==1)){
printf("Result: 1");
}
else{
printf("Result: 0");
}
default:
printf("Incorrect Operator Choice");
}
printf("\nDo yo Want to continue press 1 and 0 for close:");
scanf("%d",& test);
}
else{
printf("Incorrect Input");
getch();
printf("\nDo yo Want to continue press 1 and 0 for close:");
scanf("%d",& test);
}
}while(test);
}