summaryrefslogtreecommitdiff
path: root/45/CH10/EX10.12/example_10_12.sce
blob: 258fea5bae6fbb9cb746ffe594381a9deb0e4a6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//example 10.12
clc
clear
//pro= ('Enter the value to whic counter should progress:');
pro =11; // given input 
q=1;
aa=pro;
for i=1:4             //converting the given number in to binary 
    x=modulo(aa,2);
    b(q)=x;
    aa=aa/2;
    aa=floor(aa);
    q=q+1; 
end
           
bi=' ';   // then printing the NAND gate inputs 
for i=1:4
    if i==1 & b(i)==1 then
        bi=strcat([bi 'Qa']);
    elseif i==1 & b(i)== 0 ;
        bi=strcat([bi 'Qa''']);   
    end
    if i==2 & b(i)==1 then
        bi=strcat([bi 'Qb']);
    elseif i==2 & b(i)== 0 ;
        bi=strcat([bi 'Qb''']);   
    end
    if i==3 & b(i)==1 then
        bi=strcat([bi 'Qc']);
    elseif i==3 & b(i)== 0 ;
        bi=strcat([bi 'Qc''']);   
    end
    if i==4 & b(i)==1 then
        bi=strcat([bi 'Qd']);
    elseif i==4 & b(i)== 0 ;
        bi=strcat([bi 'Qd''']);   
    end

end
disp('The NAND gate inputs must be :'); 
disp(bi)