summaryrefslogtreecommitdiff
path: root/Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.6/Ex3_6.R
diff options
context:
space:
mode:
Diffstat (limited to 'Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.6/Ex3_6.R')
-rw-r--r--Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.6/Ex3_6.R21
1 files changed, 21 insertions, 0 deletions
diff --git a/Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.6/Ex3_6.R b/Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.6/Ex3_6.R
new file mode 100644
index 00000000..e1dfbb14
--- /dev/null
+++ b/Numerical_Methods_by_E_Balaguruswamy/CH3/EX3.6/Ex3_6.R
@@ -0,0 +1,21 @@
+# Example 6 Chapter 3 Page no.: 49
+# Octal Number to Hexadecimal
+
+
+oct <- 243 # Octal number
+decimalNumber <- 0
+i=0
+
+#Algorithm for Conversion of octal to decimal
+while(oct != 0)
+{
+ decimalNumber = decimalNumber + (oct %% 10)*(8^i)
+ i =i+1
+ oct = as.integer(oct/10)
+}
+
+H <- as.hexmode(decimalNumber[1])
+
+cat("The number 243 in Octal system is")
+H
+cat("in Hexadecimal system.")