summaryrefslogtreecommitdiff
path: root/45/CH10/EX10.12/example_10_12.sce
diff options
context:
space:
mode:
Diffstat (limited to '45/CH10/EX10.12/example_10_12.sce')
-rwxr-xr-x45/CH10/EX10.12/example_10_12.sce42
1 files changed, 42 insertions, 0 deletions
diff --git a/45/CH10/EX10.12/example_10_12.sce b/45/CH10/EX10.12/example_10_12.sce
new file mode 100755
index 000000000..258fea5ba
--- /dev/null
+++ b/45/CH10/EX10.12/example_10_12.sce
@@ -0,0 +1,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)
+