summaryrefslogtreecommitdiff
path: root/45/CH4/EX4.10/exmple_4_10.sce
diff options
context:
space:
mode:
Diffstat (limited to '45/CH4/EX4.10/exmple_4_10.sce')
-rwxr-xr-x45/CH4/EX4.10/exmple_4_10.sce15
1 files changed, 15 insertions, 0 deletions
diff --git a/45/CH4/EX4.10/exmple_4_10.sce b/45/CH4/EX4.10/exmple_4_10.sce
new file mode 100755
index 000000000..68697dc2c
--- /dev/null
+++ b/45/CH4/EX4.10/exmple_4_10.sce
@@ -0,0 +1,15 @@
+//example 4.10
+clc;
+clear;
+//sel= input('Enter which is pressed(1 - 9) : ');
+sel=6;
+aa=sel;
+for i=4:-1:1 //converting the sel input to binary notation
+ a(1,i)=modulo(aa,2);
+ b(1,i)=bitcmp(a(1,i),1);
+ aa=aa/2;
+ aa=floor(aa);
+end
+printf('When switch %d is pressed the ABCD output is :',sel);
+disp(b); //displaying the result
+printf(' Which is equivalent to %d when the output is complimented.In the output above a ''0'' represents a LOW and a ''1'' represents a HIGH. ',sel );