summaryrefslogtreecommitdiff
path: root/3808/CH4/EX4.5/Ex4_5.sce
diff options
context:
space:
mode:
Diffstat (limited to '3808/CH4/EX4.5/Ex4_5.sce')
-rw-r--r--3808/CH4/EX4.5/Ex4_5.sce46
1 files changed, 46 insertions, 0 deletions
diff --git a/3808/CH4/EX4.5/Ex4_5.sce b/3808/CH4/EX4.5/Ex4_5.sce
new file mode 100644
index 000000000..787eb006c
--- /dev/null
+++ b/3808/CH4/EX4.5/Ex4_5.sce
@@ -0,0 +1,46 @@
+//Chapter 04:Number Theory and Cryptography
+
+clc;
+clear all;
+
+dec=[]
+d=0
+i=1
+disp('Please enter input in inverted commas')
+hex=input("Enter the hexadecimal number:")
+l=length(hex)
+hex=strsplit(hex)
+cn=0
+for i=l:-1:1
+ select hex(i)
+ case 'A' then
+ d=10
+ case 'B' then
+ d=11
+ case 'C' then
+ d=12
+ case 'D' then
+ d=13
+ case 'E' then
+ d=14
+ case 'F' then
+ d=15
+ case 'a' then
+ d=10
+ case 'b' then
+ d=11
+ case 'c' then
+ d=12
+ case 'd' then
+ d=13
+ case 'e' then
+ d=14
+ case 'f' then
+ d=15
+ else
+ d=eval(hex(i))
+ end
+ dec=dec+ (d) *(16**cn)
+ cn=cn+1
+end
+disp(dec)