summaryrefslogtreecommitdiff
path: root/3808/CH4/EX4.9/Ex4_9.sce
diff options
context:
space:
mode:
authorprashantsinalkar2017-10-10 12:27:19 +0530
committerprashantsinalkar2017-10-10 12:27:19 +0530
commit7f60ea012dd2524dae921a2a35adbf7ef21f2bb6 (patch)
treedbb9e3ddb5fc829e7c5c7e6be99b2c4ba356132c /3808/CH4/EX4.9/Ex4_9.sce
parentb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (diff)
downloadScilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.tar.gz
Scilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.tar.bz2
Scilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.zip
initial commit / add all books
Diffstat (limited to '3808/CH4/EX4.9/Ex4_9.sce')
-rw-r--r--3808/CH4/EX4.9/Ex4_9.sce25
1 files changed, 25 insertions, 0 deletions
diff --git a/3808/CH4/EX4.9/Ex4_9.sce b/3808/CH4/EX4.9/Ex4_9.sce
new file mode 100644
index 000000000..c961b295c
--- /dev/null
+++ b/3808/CH4/EX4.9/Ex4_9.sce
@@ -0,0 +1,25 @@
+//Chapter 04:Number Theory and Cryptography
+
+clc;
+clear all;
+
+bin_a=[]
+i=1
+rem=0
+n1=input("Enter 1st binary number:")
+n2=input("Enter 2nd binary number:")
+t1=n1
+t2=n2
+while (n1~=0 | n2~=0)
+ bin_a($+i)=modulo((modulo(n1,10)+modulo(n2,10)+rem),2)
+ rem=(modulo(n1,10)+modulo(n2,10)+rem)/2
+ n1=int(n1/10)
+ n2=int(n2/10)
+end
+if rem ~=0 then
+ bin_a($+i)=rem
+end
+bin_a=int(bin_a)
+bin_a=flipdim(bin_a,1)
+mprintf("The sum of binary numbers %d and %d is",t1,t2)
+disp(bin_a)