diff options
Diffstat (limited to '3808/CH4/EX4.9/Ex4_9.sce')
-rw-r--r-- | 3808/CH4/EX4.9/Ex4_9.sce | 25 |
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) |