blob: 4348d92b816b5dd88b4a039fd71224a7621621f1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
//Chapter 23, Example 23.23
clc
//Initialisation
x=[9 4 5 0] //decimal number to be convert
//Calculation
//using for loop for converting each decimal to BCD
n=4
m=4
disp("BCD is ")
for i = 1:n
z=dec2bin(x(i),m) //decimal to binary conversion
printf(z)
printf(" ") //display of BCD
end
|