diff options
author | priyanka | 2015-06-24 15:03:17 +0530 |
---|---|---|
committer | priyanka | 2015-06-24 15:03:17 +0530 |
commit | b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch) | |
tree | ab291cffc65280e58ac82470ba63fbcca7805165 /1238 | |
download | Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.gz Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.bz2 Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.zip |
initial commit / add all books
Diffstat (limited to '1238')
122 files changed, 3631 insertions, 0 deletions
diff --git a/1238/CH1/EX1.1.a/1_a.sce b/1238/CH1/EX1.1.a/1_a.sce new file mode 100755 index 000000000..c79bd4e8b --- /dev/null +++ b/1238/CH1/EX1.1.a/1_a.sce @@ -0,0 +1,11 @@ +//decimal to binary conversion//
+//example 1.a//
+clc
+//clears the command window//
+clear
+//clears//
+//decimal to binary conversion//
+a=dec2bin(1993)
+disp('binary equivalent of decimal number:')
+disp(a)
+//answer in binary form//
diff --git a/1238/CH1/EX1.1.b/1_b.sce b/1238/CH1/EX1.1.b/1_b.sce new file mode 100755 index 000000000..d6a77fecd --- /dev/null +++ b/1238/CH1/EX1.1.b/1_b.sce @@ -0,0 +1,11 @@ +//binary to decimal conversion//
+//example 1.b//
+clc
+//clears the command window//
+clear
+//clears//
+//binary to decimal conversion//
+a=bin2dec('11111001001')
+disp('decimal equivalent of binary number:')
+disp(a)
+//answer in decimal form//
diff --git a/1238/CH1/EX1.10.a/10_a.sce b/1238/CH1/EX1.10.a/10_a.sce new file mode 100755 index 000000000..9d35a2448 --- /dev/null +++ b/1238/CH1/EX1.10.a/10_a.sce @@ -0,0 +1,11 @@ +//hex to decimal conversion//
+//example 10.a//
+clc
+//clears the command window//
+clear
+//clears//
+//hex to decimal conversion//
+x='7C9'
+a=hex2dec(x)
+disp('the number in decimal form is:')
+disp(a)
diff --git a/1238/CH1/EX1.10.b/10_b.sce b/1238/CH1/EX1.10.b/10_b.sce new file mode 100755 index 000000000..9fff80822 --- /dev/null +++ b/1238/CH1/EX1.10.b/10_b.sce @@ -0,0 +1,11 @@ +//decimal to hex conversion//
+//example 10.b//
+clc
+//clears the command window//
+clear
+//clears//
+//decimal to hex conversion//
+x=2047
+a=dec2hex(2047)
+disp('the result in hex form is:')
+disp(a)
diff --git a/1238/CH1/EX1.11/11.sce b/1238/CH1/EX1.11/11.sce new file mode 100755 index 000000000..b2bf00fa1 --- /dev/null +++ b/1238/CH1/EX1.11/11.sce @@ -0,0 +1,13 @@ +//hex to binary and decimal conversion//
+//example 11//
+clc
+//clears the command window//
+clear
+//clears//
+//decimal conversion//
+x='CD42'
+a=hex2dec('CD42');//hex to decimal conversion//
+disp(a);//answer displayed in decimal form//
+//binary conversion//
+b=dec2bin(a);//dedcimal to binary conversion//
+disp(b);//answer displayed in binary form//
diff --git a/1238/CH1/EX1.12/12.sce b/1238/CH1/EX1.12/12.sce new file mode 100755 index 000000000..a5563782d --- /dev/null +++ b/1238/CH1/EX1.12/12.sce @@ -0,0 +1,15 @@ +//hex to binary,octal and decimal conversion//
+//example 12//
+clc
+//clears the command window//
+clear
+//clears//
+//decimal conversion//
+x='100'
+d=hex2dec(x);//hex to decimal conversion//
+b=dec2bin(d);//decimal to binary conversion//
+o=dec2oct(d);//decimal to octal conversion//
+disp(d);//answer in decimal form//
+disp(b);//answer in binary form//
+disp(o);//answer in octal form//
+
diff --git a/1238/CH1/EX1.13.a/13_a.sce b/1238/CH1/EX1.13.a/13_a.sce new file mode 100755 index 000000000..08f46bb54 --- /dev/null +++ b/1238/CH1/EX1.13.a/13_a.sce @@ -0,0 +1,10 @@ +//hex to decimal conversion//
+//example 13.a//
+clc
+//clears the command window//
+clear
+//clears//
+x='D2763'
+a=hex2dec('D2763')
+disp('the result in decimal form:')
+disp(a)
diff --git a/1238/CH1/EX1.13.b/13_b.sce b/1238/CH1/EX1.13.b/13_b.sce new file mode 100755 index 000000000..fe6e1d30b --- /dev/null +++ b/1238/CH1/EX1.13.b/13_b.sce @@ -0,0 +1,10 @@ +//hex to decimal conversion//
+//example 13.b//
+clc
+//clears the command window//
+clear
+//clears//
+x='B3D8'
+a=hex2dec('B3D8')
+disp('the result in decimal form:')
+disp(a)
diff --git a/1238/CH1/EX1.14.a/14_a.sce b/1238/CH1/EX1.14.a/14_a.sce new file mode 100755 index 000000000..2f45c0061 --- /dev/null +++ b/1238/CH1/EX1.14.a/14_a.sce @@ -0,0 +1,16 @@ +//addition of two numbers//
+//example 14.a//
+clc
+//clears the command window//
+clear
+//clears//
+//addition of two binary numbers//
+//binary to decimal conversion//
+x=bin2dec('100101')
+y=bin2dec('100101')
+z=x+y
+//addition//
+a=dec2bin(z)
+//decimal to binary conversion//
+disp('the addition of two binary numbers is:')
+disp(a)
diff --git a/1238/CH1/EX1.14.b/14_b.sce b/1238/CH1/EX1.14.b/14_b.sce new file mode 100755 index 000000000..d7fd2f025 --- /dev/null +++ b/1238/CH1/EX1.14.b/14_b.sce @@ -0,0 +1,131 @@ +//addition of two binary numbers//
+//example 14.b//
+clc
+//clears the command window//
+clear
+// clears //;//decimal equivalent of the first binary number//
+//addition of two binary numbers//
+p =1;
+// initialising //
+q =1;
+z =0;
+b =0;
+w =0;
+f =0;
+//bin=1st input ( Enter the binary no to be converted to its decimal equivalent : )
+//accepting the binary input from user//
+bin =1011.01;
+d =modulo(bin ,1);
+//separating the decimal part and the integer part//
+d=d *10^10;
+a = floor (bin) ;
+//removing the decimal part//
+while (a >0)
+//Loop to take the binary bits of integer into a matrix //
+r = modulo (a ,10) ;
+b(1,q) = r ;
+a=a /10;
+a= floor ( a ) ;
+q=q +1;
+end
+ for m =1: q -1
+ // multipliying the bits of integer position values and adding//
+ c=m -1;
+ f=f+b(1,m) *(2^ c);
+ end
+ while (d >0)
+ // Loop to take the binary bits of decimal into a matrix//
+ e = modulo (d ,2)
+ w(1 ,p)=e
+ d = d /10;
+ d= floor (d)
+ p=p +1;
+ end
+ for n =1: p -1
+ // multipliying the bits of decimal with their position values and adding//
+ z=z+w(1 ,n)*(0.5) ^(11 -n);
+ end
+z = z *10000;
+//rounding of to 4 decimal values//
+z= round (z);
+z = z /10000;
+x1=f+z;
+disp ( 'The Decimal equivalent of the first binary number given is ' );
+disp (x1);
+//to find decimal equivalent of second binary number//
+//bin=2nd input ( Enter the binary no to be converted to its decimal equivalent : )
+p =1;
+// initialising //
+q =1;
+z =0;
+b =0;
+w =0;
+f =0;
+//accepting the binary input from user//
+bin =1001.11;
+d =modulo(bin ,1);
+//separating the decimal part and the integer part//
+d=d *10^10;
+a = floor (bin) ;
+//removing the decimal part//
+while (a >0)
+//Loop to take the binary bits of integer into a matrix //
+r = modulo (a ,10) ;
+b(1,q) = r ;
+a=a /10;
+a= floor ( a ) ;
+q=q +1;
+end
+ for m =1: q -1
+ // multipliying the bits of integer position values and adding//
+ c=m -1;
+ f=f+b(1,m) *(2^ c);
+ end
+while (d >0)
+ // Loop to take the binary bits of decimal into a matrix//
+ e = modulo (d ,2)
+ w(1 ,p)=e
+ d = d /10;
+ d= floor (d)
+ p=p +1;
+ end
+ for n =1: p -1
+ // multipliying the bits of decimal with their position values and adding//
+ z=z+w(1 ,n)*(0.5) ^(11 -n);
+ end
+z = z *10000;
+//rounding of to 4 decimal values//
+z= round (z);
+z = z /10000;
+x2=f+z;
+disp ( 'The Decimal equivalent of the second binary number given is ' );
+disp (x2);
+res=x1+x2;//addition//
+//decimal to binary conversion//
+q=0;
+b=0;
+s=0;
+//enter the decimal number to be converted//
+a=res;
+d=modulo(a,1);//separating decimal and integer part//
+a=floor(a);//removing decimal part//
+while (a>0)
+//taking integer part into a matrix and converting to equivalent binary//
+x=modulo(a,2)
+b=b+(10^q)*x
+a=a/2
+a=floor(a)
+q=q+1
+end
+for i=1:10
+//for values after decimal that should be converted to binary//
+d=d*2
+q=floor(d)
+s=s+q/(10^i);
+if d>=1 then
+ d=d-1
+ end
+ end
+k=b+s;
+disp('the addition of two binary numbers is')
+disp(k);//displaying the result//
diff --git a/1238/CH1/EX1.14.c/14_c.sce b/1238/CH1/EX1.14.c/14_c.sce new file mode 100755 index 000000000..3b8779ce7 --- /dev/null +++ b/1238/CH1/EX1.14.c/14_c.sce @@ -0,0 +1,131 @@ +//addition of two binary numbers//
+//example 14.c//
+clc
+//clears the command window//
+clear
+// clears //;
+//addition of two binary numbers//
+//decimal equivalent of the first binary number//
+p =1;
+// initialising //
+q =1;
+z =0;
+b =0;
+w =0;
+f =0;
+//bin=1st input ( Enter the binary no to be converted to its decimal equivalent : )
+//accepting the binary input from user//
+bin =1100.011;
+d =modulo(bin ,1);
+//separating the decimal part and the integer part//
+d=d *10^10;
+a = floor (bin) ;
+//removing the decimal part//
+while (a >0)
+//Loop to take the binary bits of integer into a matrix //
+r = modulo (a ,10) ;
+b(1,q) = r ;
+a=a /10;
+a= floor ( a ) ;
+q=q +1;
+end
+ for m =1: q -1
+ // multipliying the bits of integer position values and adding//
+ c=m -1;
+ f=f+b(1,m) *(2^ c);
+ end
+ while (d >0)
+ // Loop to take the binary bits of decimal into a matrix//
+ e = modulo (d ,2)
+ w(1 ,p)=e
+ d = d /10;
+ d= floor (d)
+ p=p +1;
+ end
+ for n =1: p -1
+ // multipliying the bits of decimal with their position values and adding//
+ z=z+w(1 ,n)*(0.5) ^(11 -n);
+end
+z = z *10000;
+//rounding of to 4 decimal values//
+z= round (z);
+z = z /10000;
+x1=f+z;
+disp ( 'The Decimal equivalent of the first binary number given is ');
+disp (x1);
+//to find decimal equivalent of second binary number//
+//bin=2nd input ( Enter the binary no to be converted to its decimal equivalent : )
+p =1;
+// initialising //
+q =1;
+z =0;
+b =0;
+w =0;
+f =0;
+//accepting the binary input from user//
+bin =1011.011;
+d =modulo(bin ,1);
+//separating the decimal part and the integer part//
+d=d *10^10;
+a = floor (bin) ;
+//removing the decimal part//
+while (a >0)
+//Loop to take the binary bits of integer into a matrix //
+r = modulo (a ,10) ;
+b(1,q) = r ;
+a=a /10;
+a= floor ( a ) ;
+q=q +1;
+ end
+ for m =1: q -1
+ // multipliying the bits of integer position values and adding//
+ c=m -1;
+ f=f+b(1,m) *(2^ c);
+ end
+ while (d >0)
+ // Loop to take the binary bits of decimal into a matrix//
+ e = modulo (d ,2)
+ w(1 ,p)=e
+ d = d /10;
+ d= floor (d)
+ p=p +1;
+ end
+ for n =1: p -1
+ // multipliying the bits of decimal with their position values and adding//
+ z=z+w(1 ,n)*(0.5) ^(11 -n);
+ end
+z = z *10000;
+//rounding of to 4 decimal values//
+z= round (z);
+z = z /10000;
+x2=f+z;
+disp ( 'The Decimal equivalent of the second binary number given is ' );
+disp (x2);
+res=x1+x2;//addition//
+q=0;//binary conversion of the decimal answer begins here//
+b=0;
+s=0;
+//enter the decimal number to be converted//
+a=res;
+d=modulo(a,1);//separating decimal and integer part//
+a=floor(a);//removing decimal part//
+while (a>0)
+//taking integer part into a matrix and converting to equivalent binary//
+x=modulo(a,2)
+b=b+(10^q)*x
+a=a/2
+a=floor(a)
+q=q+1
+ end
+ for i=1:10
+ //for values after decimal that should be converted to binary//
+ d=d*2
+ q=floor(d)
+ s=s+q/(10^i);
+ if d>=1 then
+ d=d-1
+ end
+ end
+k=b+s;
+disp('the addition of two numbers give:')
+disp(k);//displaying the result//
diff --git a/1238/CH1/EX1.15.a/15_a.sce b/1238/CH1/EX1.15.a/15_a.sce new file mode 100755 index 000000000..f1606ff1c --- /dev/null +++ b/1238/CH1/EX1.15.a/15_a.sce @@ -0,0 +1,130 @@ +//subtraction of two binary numbers//
+//example 15.a//
+clc
+//clears the command window//
+clear
+// clears //;
+//decimal equivalent of the first binary number//
+p =1;
+// initialising //
+q =1;
+z =0;
+b =0;
+w =0;
+f =0;
+//bin=1st input ( Enter the binary no to be converted to its decimal equivalent : )
+//accepting the binary input from user//
+bin1=110.01;
+d =modulo(bin1 ,1);
+//separating the decimal part and the integer part//
+d=d *10^10;
+a = floor (bin1) ;
+//removing the decimal part//
+ while (a >0)
+ //Loop to take the binary bits of integer into a matrix //
+ r = modulo (a ,10) ;
+ b(1,q) = r ;
+ a=a /10;
+ a= floor ( a ) ;
+ q=q +1;
+ end
+ for m =1: q -1
+ // multipliying the bits of integer position values and adding//
+ c=m -1;
+ f=f+b(1,m) *(2^ c);
+ end
+ while (d >0)
+ // Loop to take the binary bits of decimal into a matrix//
+ e = modulo (d ,2)
+ w(1 ,p)=e
+ d = d /10;
+ d= floor (d)
+ p=p +1;
+ end
+ for n =1: p -1
+ // multipliying the bits of decimal with their position values and adding//
+ z=z+w(1 ,n)*(0.5) ^(11 -n);
+ end
+z = z *10000;
+//rounding of to 4 decimal values//
+z= round (z);
+z = z /10000;
+x1=f+z;
+disp ( 'The Decimal equivalent of the first binary number given is ' );
+disp (x1);
+//to find decimal equivalent of second binary number//
+//bin=2nd input ( Enter the binary no to be converted to its decimal equivalent : )
+p =1;
+// initialising //
+q =1;
+z =0;
+b =0;
+w =0;
+f =0;
+//accepting the binary input from user//
+bin2=100.10;
+d =modulo(bin2,1);
+//separating the decimal part and the integer part//
+d=d *10^10;
+a = floor(bin2) ;
+//removing the decimal part//
+ while (a >0)
+ //Loop to take the binary bits of integer into a matrix //
+ r = modulo (a ,10) ;
+ b(1,q) = r ;
+ a=a /10;
+ a= floor ( a ) ;
+ q=q +1;
+ end
+ for m =1: q -1
+ // multipliying the bits of integer position values and adding//
+ c=m -1;
+ f=f+b(1,m) *(2^ c);
+ end
+ while (d >0)
+ // Loop to take the binary bits of decimal into a matrix//
+ e = modulo (d ,2)
+ w(1 ,p)=e
+ d = d /10;
+ d= floor (d)
+ p=p +1;
+ end
+ for n =1: p -1
+ // multipliying the bits of decimal with their position values and adding//
+ z=z+w(1 ,n)*(0.5) ^(11 -n);
+ end
+z = z *10000;
+//rounding of to 4 decimal values//
+z= round (z);
+z = z /10000;
+x2=f+z;
+disp ( 'The Decimal equivalent of the second binary number given is ' );
+disp (x2);
+res=x1-x2;//subtraction//
+q=0;//binary conversion of the decimal answer begins here//
+b=0;
+s=0;
+//enter the decimal number to be converted//
+a=res;
+d=modulo(a,1);//separating decimal and integer part//
+a=floor(a);//removing decimal part//
+while (a>0)
+//taking integer part into a matrix and converting to equivalent binary//
+x=modulo(a,2)
+b=b+(10^q)*x
+a=a/2
+a=floor(a)
+q=q+1
+ end
+ for i=1:10
+ //for values after decimal that should be converted to binary//
+ d=d*2
+ q=floor(d)
+ s=s+q/(10^i);
+ if d>=1 then
+ d=d-1
+ end
+ end
+k=b+s;
+disp('the subtraction of two numbers give:')
+disp(k);//displaying the result//
diff --git a/1238/CH1/EX1.15.b/15_b.sce b/1238/CH1/EX1.15.b/15_b.sce new file mode 100755 index 000000000..cab1fbcda --- /dev/null +++ b/1238/CH1/EX1.15.b/15_b.sce @@ -0,0 +1,130 @@ +//subtraction of two binary numbers//
+//example 15.b//
+clc
+//clears the command window//
+clear
+// clears //;//decimal equivalent of the first binary number//
+p =1;
+// initialising //
+q =1;
+z =0;
+b =0;
+w =0;
+f =0;
+//bin=1st input ( Enter the binary no to be converted to its decimal equivalent : )
+//accepting the binary input from user//
+bin =11.01111;
+d =modulo(bin ,1);
+//separating the decimal part and the integer part//
+d=d *10^10;
+a = floor (bin) ;
+//removing the decimal part//
+ while (a >0)
+ //Loop to take the binary bits of integer into a matrix //
+ r = modulo (a ,10) ;
+ b(1,q) = r ;
+ a=a /10;
+ a= floor ( a ) ;
+ q=q +1;
+ end
+ for m =1: q -1
+ // multipliying the bits of integer position values and adding//
+ c=m -1;
+ f=f+b(1,m) *(2^ c);
+ end
+ while (d >0)
+ // Loop to take the binary bits of decimal into a matrix//
+ e = modulo (d ,2)
+ w(1 ,p)=e
+ d = d /10;
+ d= floor (d)
+ p=p +1;
+ end
+ for n =1: p -1
+ // multipliying the bits of decimal with their position values and adding//
+ z=z+w(1 ,n)*(0.5) ^(11 -n);
+ end
+z = z *10000;
+//rounding of to 4 decimal values//
+z= round (z);
+z = z /10000;
+x1=f+z;
+disp ( 'The Decimal equivalent of the first binary number given is ' );
+disp (x1);
+//to find decimal equivalent of second binary number//
+//bin=2nd input ( Enter the binary no to be converted to its decimal equivalent : )
+p =1;
+// initialising //
+q =1;
+z =0;
+b =0;
+w =0;
+f =0;
+//accepting the binary input from user//
+bin =10.01001;
+d =modulo(bin ,1);
+//separating the decimal part and the integer part//
+d=d *10^10;
+a = floor (bin) ;
+//removing the decimal part//
+ while (a >0)
+ //Loop to take the binary bits of integer into a matrix //
+ r = modulo (a ,10) ;
+ b(1,q) = r ;
+ a=a /10;
+ a= floor ( a ) ;
+ q=q +1;
+ end
+ for m =1: q -1
+ // multipliying the bits of integer position values and adding//
+ c=m -1;
+ f=f+b(1,m) *(2^ c);
+ end
+ while (d >0)
+ // Loop to take the binary bits of decimal into a matrix//
+ e = modulo (d ,2)
+ w(1 ,p)=e
+ d = d /10;
+ d= floor (d)
+ p=p +1;
+ end
+ for n =1: p -1
+ // multipliying the bits of decimal with their position values and adding//
+ z=z+w(1 ,n)*(0.5) ^(11 -n);
+ end
+z = z *10000;
+//rounding of to 4 decimal values//
+z= round (z);
+z = z /10000;
+x2=f+z;
+disp ( 'The Decimal equivalent of the second binary number given is ' );
+disp (x2);
+res=x1-x2;//subtraction//
+q=0;//binary conversion of the decimal answer begins here//
+b=0;
+s=0;
+//enter the decimal number to be converted//
+a=res;
+d=modulo(a,1);//separating decimal and integer part//
+a=floor(a);//removing decimal part//
+while (a>0)
+//taking integer part into a matrix and converting to equivalent binary//
+x=modulo(a,2)
+b=b+(10^q)*x
+a=a/2
+a=floor(a)
+q=q+1
+ end
+ for i=1:10
+ //for values after decimal that should be converted to binary//
+ d=d*2
+ q=floor(d)
+ s=s+q/(10^i);
+ if d>=1 then
+ d=d-1
+ end
+ end
+k=b+s;
+disp('the subtraction of two numbers give:')
+disp(k);//displaying the result//
+
diff --git a/1238/CH1/EX1.16.a/16_a.sce b/1238/CH1/EX1.16.a/16_a.sce new file mode 100755 index 000000000..5f9c87ce9 --- /dev/null +++ b/1238/CH1/EX1.16.a/16_a.sce @@ -0,0 +1,129 @@ +//multiplication of two binary numbers//
+//example 16.a//
+clc
+//clears the command window//
+clear
+// clears //;//decimal equivalent of the first binary number//
+p =1;
+// initialising //
+q =1;
+z =0;
+b =0;
+w =0;
+f =0;
+//bin=1st input ( Enter the binary no to be converted to its decimal equivalent : )
+//accepting the binary input from user//
+bin =1.01;
+d =modulo(bin ,1);
+//separating the decimal part and the integer part//
+d=d *10^10;
+a = floor (bin) ;
+//removing the decimal part//
+ while (a >0)
+ //Loop to take the binary bits of integer into a matrix //
+ r = modulo (a ,10) ;
+ b(1,q) = r ;
+ a=a /10;
+ a= floor ( a ) ;
+ q=q +1;
+ end
+ for m =1: q -1
+ // multipliying the bits of integer position values and adding//
+ c=m -1;
+ f=f+b(1,m) *(2^ c);
+ end
+ while (d >0)
+ // Loop to take the binary bits of decimal into a matrix//
+ e = modulo (d ,2)
+ w(1 ,p)=e
+ d = d /10;
+ d= floor (d)
+ p=p +1;
+ end
+ for n =1: p -1
+ // multipliying the bits of decimal with their position values and adding//
+ z=z+w(1 ,n)*(0.5) ^(11 -n);
+ end
+z = z *10000;
+//rounding of to 4 decimal values//
+z= round (z);
+z = z /10000;
+x1=f+z;
+disp ( 'The Decimal equivalent of the first binary number given is ' );
+disp (x1);
+//to find decimal equivalent of second binary number//
+//bin=2nd input ( Enter the binary no to be converted to its decimal equivalent : )
+p =1;
+// initialising //
+q =1;
+z =0;
+b =0;
+w =0;
+f =0;
+//accepting the binary input from user//
+bin =10.1;
+d =modulo(bin ,1);
+//separating the decimal part and the integer part//
+d=d *10^10;
+a = floor (bin) ;
+//removing the decimal part//
+ while (a >0)
+ //Loop to take the binary bits of integer into a matrix //
+ r = modulo (a ,10) ;
+ b(1,q) = r ;
+ a=a /10;
+ a= floor ( a ) ;
+ q=q +1;
+ end
+ for m =1: q -1
+ // multipliying the bits of integer position values and adding//
+ c=m -1;
+ f=f+b(1,m) *(2^ c);
+ end
+ while (d >0)
+ // Loop to take the binary bits of decimal into a matrix//
+ e = modulo (d ,2)
+ w(1 ,p)=e
+ d = d /10;
+ d= floor (d)
+ p=p +1;
+ end
+ for n =1: p -1
+ // multipliying the bits of decimal with their position values and adding//
+ z=z+w(1 ,n)*(0.5) ^(11 -n);
+ end
+z = z *10000;
+//rounding of to 4 decimal values//
+z= round (z);
+z = z /10000;
+x2=f+z;
+disp ( 'The Decimal equivalent of the second binary number given is ' );
+disp (x2);
+res=x1*x2;//multiplication//
+q=0;//binary conversion of the decimal answer begins here//
+b=0;
+s=0;
+//enter the decimal number to be converted//
+a=res;
+d=modulo(a,1);//separating decimal and integer part//
+a=floor(a);//removing decimal part//
+while (a>0)
+//taking integer part into a matrix and converting to equivalent binary//
+x=modulo(a,2)
+b=b+(10^q)*x
+a=a/2
+a=floor(a)
+q=q+1
+ end
+ for i=1:10
+ //for values after decimal that should be converted to binary//
+ d=d*2
+ q=floor(d)
+ s=s+q/(10^i);
+ if d>=1 then
+ d=d-1
+ end
+ end
+k=b+s;
+disp('the multiplication of two numbers give:')
+disp(k);//displaying the result//
diff --git a/1238/CH1/EX1.16.b/16_b.sce b/1238/CH1/EX1.16.b/16_b.sce new file mode 100755 index 000000000..f35dd97bf --- /dev/null +++ b/1238/CH1/EX1.16.b/16_b.sce @@ -0,0 +1,90 @@ +//multiplication of two binary numbers//
+//example 16.b//
+clc
+//clears the command window//
+clear
+// clears //;
+//decimal equivalent of the first binary number//
+p =1;
+// initialising //
+q =1;
+z =0;
+b =0;
+w =0;
+f =0;
+//bin=1st input ( Enter the binary no to be converted to its decimal equivalent : )
+//accepting the binary input from user//
+bin =101.01;
+d =modulo(bin ,1);
+//separating the decimal part and the integer part//
+d=d *10^10;
+a = floor (bin) ;
+//removing the decimal part//
+ while (a >0)
+ //Loop to take the binary bits of integer into a matrix //
+ r = modulo (a ,10) ;
+ b(1,q) = r ;
+ a=a /10;
+ a= floor ( a ) ;
+ q=q +1;
+ end
+ for m =1: q -1
+ // multipliying the bits of integer position values and adding//
+ c=m -1;
+ f=f+b(1,m) *(2^ c);
+ end
+ while (d >0)
+ // Loop to take the binary bits of decimal into a matrix//
+ e = modulo (d ,2)
+ w(1 ,p)=e
+ d = d /10;
+ d= floor (d)
+ p=p +1;
+ end
+ for n =1: p -1
+ // multipliying the bits of decimal with their position values and adding//
+ z=z+w(1 ,n)*(0.5) ^(11 -n);
+ end
+z = z *10000;
+//rounding of to 4 decimal values//
+z= round (z);
+z = z /10000;
+x1=f+z;
+disp ( 'The Decimal equivalent of the first binary number given is ' );
+disp (x1);
+//to find decimal equivalent of second binary number//
+//bin=2nd input ( Enter the binary no to be converted to its decimal equivalent : )
+//accepting the binary input from user//
+bin ='11';
+x2=bin2dec(bin)
+disp ( 'The Decimal equivalent of the second binary number given is ' );
+disp (x2);
+res=x1*x2;//multiplication//
+q=0;//binary conversion of the decimal answer begins here//
+b=0;
+s=0;
+//enter the decimal number to be converted//
+a=res;
+d=modulo(a,1);//separating decimal and integer part//
+a=floor(a);//removing decimal part//
+while (a>0)
+//taking integer part into a matrix and converting to equivalent binary//
+x=modulo(a,2)
+b=b+(10^q)*x
+a=a/2
+a=floor(a)
+q=q+1
+ end
+ for i=1:10
+ //for values after decimal that should be converted to binary//
+ d=d*2
+ q=floor(d)
+ s=s+q/(10^i);
+ if d>=1 then
+ d=d-1
+ end
+ end
+k=b+s;
+disp('the multiplication of two numbers give:')
+disp(k);//displaying the result//
+
diff --git a/1238/CH1/EX1.17.a/17_a.sce b/1238/CH1/EX1.17.a/17_a.sce new file mode 100755 index 000000000..f733a9fe4 --- /dev/null +++ b/1238/CH1/EX1.17.a/17_a.sce @@ -0,0 +1,40 @@ +//division of two binary numbers//
+//example 17.a//
+clc
+//clears the command window//
+clear
+// clears //;//decimal equivalent of the first binary number//
+//bin=1st input ( Enter the binary no to be converted to its decimal equivalent : )
+//accepting the binary input from user//
+bin ='1111001';//1st input//
+x1=bin2dec(bin)
+bin='1001';//2nd input//
+x2=bin2dec(bin)
+res=x1/x2;//division//
+q=0;
+b=0;
+s=0;
+//enter the decimal number to be converted//
+a=res;
+d=modulo(a,1);//separating decimal and integer part//
+a=floor(a);//removing decimal part//
+ while (a>0)
+ //taking integer part into a matrix and converting to equivalent binary//
+ x=modulo(a,2)
+ b=b+(10^q)*x
+ a=a/2
+ a=floor(a)
+ q=q+1
+ end
+ for i=1:10
+ //for values after decimal that should be converted to binary//
+ d=d*2
+ q=floor(d)
+ s=s+q/(10^i);
+ if d>=1 then
+ d=d-1
+ end
+ end
+k=b+s;
+disp('the division of two numbers give:')
+disp(k);//displaying the result//
diff --git a/1238/CH1/EX1.17.b/17_b.sce b/1238/CH1/EX1.17.b/17_b.sce new file mode 100755 index 000000000..01c2f9296 --- /dev/null +++ b/1238/CH1/EX1.17.b/17_b.sce @@ -0,0 +1,126 @@ +//division of two binary numbers//
+//example 17.b//
+clc
+//clears the command window//
+clear
+// clears //;//decimal equivalent of the first binary number//
+p =1;
+// initialising //
+q =1;
+z =0;
+b =0;
+w =0;
+f =0;
+//bin= input ( Enter the binary no to be converted to its decimal equivalent : )
+//accepting the binary input from user//
+bin =11.11;
+d =modulo(bin ,1);
+//separating the decimal part and the integer part//
+d=d *10^10;
+a = floor (bin) ;
+//removing the decimal part//
+ while (a >0)
+ //Loop to take the binary bits of integer into a matrix //
+ r = modulo (a ,10) ;
+ b(1,q) = r ;
+ a=a /10;
+ a= floor ( a ) ;
+ q=q +1;
+ end
+ for m =1: q -1
+ // multipliying the bits of integer position values and adding//
+ c=m -1;
+ f=f+b(1,m) *(2^ c);
+ end
+ while (d >0)
+ // Loop to take the binary bits of decimal into a matrix//
+ e = modulo (d ,2)
+ w(1 ,p)=e
+ d = d /10;
+ d= floor (d)
+ p=p +1;
+ end
+ for n =1: p -1
+ // multipliying the bits of decimal with their position values and adding//
+ z=z+w(1 ,n)*(0.5) ^(11 -n);
+ end
+z = z *10000;
+//rounding of to 4 decimal values//
+z= round (z);
+z = z /10000;
+x1=f+z;
+p =1;
+// initialising //
+q =1;
+z =0;
+b =0;
+w =0;
+f =0;
+//bin=2nd input ( Enter the binary no to be converted to its decimal equivalent : )
+//accepting the binary input from user//
+bin =.101;
+d =modulo(bin ,1);
+//separating the decimal part and the integer part//
+d=d *10^10;
+a = floor (bin) ;
+//removing the decimal part//
+ while (a >0)
+ //Loop to take the binary bits of integer into a matrix //
+ r = modulo (a ,10) ;
+ b(1,q) = r ;
+ a=a /10;
+ a= floor ( a ) ;
+ q=q +1;
+ end
+ for m =1: q -1
+ // multipliying the bits of integer position values and adding//
+ c=m -1;
+ f=f+b(1,m) *(2^ c);
+ end
+ while (d >0)
+ // Loop to take the binary bits of decimal into a matrix//
+ e = modulo (d ,2)
+ w(1 ,p)=e
+ d = d /10;
+ d= floor (d)
+ p=p +1;
+ end
+ for n =1: p -1
+ // multipliying the bits of decimal with their position values and adding//
+ z=z+w(1 ,n)*(0.5) ^(11 -n);
+ end
+z = z *10000;
+//rounding of to 4 decimal values//
+z= round (z);
+z = z /10000;
+x2=f+z;
+res=x1/x2;//division//
+q=0;
+b=0;
+s=0;
+//enter the decimal number to be converted//
+a=res;
+d=modulo(a,1);//separating decimal and integer part//
+a=floor(a);//removing decimal part//
+while (a>0)
+//taking integer part into a matrix and converting to equivalent binary//
+x=modulo(a,2)
+b=b+(10^q)*x
+a=a/2
+a=floor(a)
+q=q+1
+ end
+ for i=1:10
+ //for values after decimal that should be converted to binary//
+ d=d*2
+ q=floor(d)
+ s=s+q/(10^i);
+ if d>=1 then
+ d=d-1
+ end
+ end
+k=b+s;
+disp('the division of two numbers give:')
+disp(k);//displaying the result//
+
+
diff --git a/1238/CH1/EX1.18.a/18_a.sce b/1238/CH1/EX1.18.a/18_a.sce new file mode 100755 index 000000000..8272d848a --- /dev/null +++ b/1238/CH1/EX1.18.a/18_a.sce @@ -0,0 +1,11 @@ +//binary to hex conversion//
+//example 18.a//
+clc
+//clears the command window//
+clear
+//clears//
+x='10100110'
+a=bin2dec(x);//binary to decimal conversion//
+res=dec2hex(a);//decimal to hex conversion//
+disp('the number in hexadecimal form:')
+disp(res);//answer displayed//
diff --git a/1238/CH1/EX1.18.b/18_b.sce b/1238/CH1/EX1.18.b/18_b.sce new file mode 100755 index 000000000..ac8404757 --- /dev/null +++ b/1238/CH1/EX1.18.b/18_b.sce @@ -0,0 +1,10 @@ +//decimal to octal conversion//
+//example 18.b//
+clc
+//clears the command window//
+clear
+//clears//
+x=6800
+res=dec2oct(x);//decimal to octal conversion//
+disp(res);//answer in octal form//
+
diff --git a/1238/CH1/EX1.18.c/18_c.sce b/1238/CH1/EX1.18.c/18_c.sce new file mode 100755 index 000000000..3e14fd712 --- /dev/null +++ b/1238/CH1/EX1.18.c/18_c.sce @@ -0,0 +1,53 @@ +//decimal to binary conversion//
+//example 18.c//
+clc
+//clears the command window//
+clear
+// clears //
+//converting first binary input to decimal//
+p =1;
+// initialising //
+q =1;
+z =0;
+b =0;
+w =0;
+f =0;
+//bin= input ( Enter the binary no to be converted to its decimal equivalent : )
+bin =.0111;
+d =modulo(bin ,1);
+//separating the decimal part and the integer part//
+d=d *10^10;
+a = floor (bin) ;
+//removing the decimal part//
+while (a >0)
+ //Loop to take the binary bits of integer into a matrix //
+ r = modulo (a ,10) ;
+ b(1,q) = r ;
+ a=a /10;
+ a= floor ( a ) ;
+ q=q +1;
+ end
+ for m =1: q -1
+ // multipliying the bits of integer position values and adding//
+ c=m -1;
+ f=f+b(1,m) *(2^ c);
+ end
+ while (d >0)
+ // Loop to take the binary bits of decimal into a matrix//
+ e = modulo (d ,2)
+ w(1 ,p)=e
+ d = d /10;
+ d= floor (d)
+ p=p +1;
+ end
+ for n =1: p -1
+ // multipliying the bits of decimal with their position values and adding//
+ z=z+w(1 ,n)*(0.5) ^(11 -n);
+ end
+z = z *10000;
+//rounding of to 4 decimal values//
+z= round (z);
+z = z /10000;
+d1=f+z;
+disp('the number in binary form:')
+disp(d1);//displaying the result//
diff --git a/1238/CH1/EX1.19.a/19_a.sce b/1238/CH1/EX1.19.a/19_a.sce new file mode 100755 index 000000000..f423875b8 --- /dev/null +++ b/1238/CH1/EX1.19.a/19_a.sce @@ -0,0 +1,32 @@ +//decimal to octal conversion//
+//example 19.a//
+clc
+//clears the command window//
+clear
+//clears//
+//decimal to octal conversion//
+q=0;
+b=0;
+s=0;
+//enter the decimal number to be converted//
+a=4429.625;
+d=modulo(a,1);//separating decimal and integer part//
+a=floor(a);//removing decimal part//
+ while (a>0)
+ //taking integer part into a matrix and converting to equivalent octal//
+ x=modulo(a,8)
+ b=b+(10^q)*x
+ a=a/8
+ a=floor(a)
+ q=q+1
+ end
+ for i=1:10
+ //for values after decimal that should be converted to octal//
+ d=d*8
+ q=floor(d)
+ s=s+q/(10^i);
+ d=d-q
+ end
+k=b+s;
+disp('the octal equivalent of the given decimal number is')
+disp(k);//displaying the result//
diff --git a/1238/CH1/EX1.19.b/19_b.sce b/1238/CH1/EX1.19.b/19_b.sce new file mode 100755 index 000000000..68260667c --- /dev/null +++ b/1238/CH1/EX1.19.b/19_b.sce @@ -0,0 +1,32 @@ +//decimal to octal conversion//
+//example 19.b//
+clc
+//clears the command window//
+clear
+//clears//
+//decimal to octal conversion//
+q=0;
+b=0;
+s=0;
+//enter the decimal number to be converted//
+a=791.125;
+d=modulo(a,1);//separating decimal and integer part//
+a=floor(a);//removing decimal part//
+ while (a>0)
+ //taking integer part into a matrix and converting to equivalent octal//
+ x=modulo(a,8)
+ b=b+(10^q)*x
+ a=a/8
+ a=floor(a)
+ q=q+1
+ end
+ for i=1:10
+ //for values after decimal that should be converted to octal//
+ d=d*8
+ q=floor(d)
+ s=s+q/(10^i);
+ d=d-q
+ end
+k=b+s;
+disp('the octal equivalent of the given decimal number is')
+disp(k);//displaying the result//
diff --git a/1238/CH1/EX1.19.c/19_c.sce b/1238/CH1/EX1.19.c/19_c.sce new file mode 100755 index 000000000..63477b3ed --- /dev/null +++ b/1238/CH1/EX1.19.c/19_c.sce @@ -0,0 +1,32 @@ +//decimal to octal conversion//
+//example 19.c//
+clc
+//clears the command window//
+clear
+//clears//
+//decimal to octal conversion//
+q=0;
+b=0;
+s=0;
+//enter the decimal number to be converted//
+a=11.9375;
+d=modulo(a,1);//separating decimal and integer part//
+a=floor(a);//removing decimal part//
+ while (a>0)
+ //taking integer part into a matrix and converting to equivalent octal//
+ x=modulo(a,8)
+ b=b+(10^q)*x
+ a=a/8
+ a=floor(a)
+ q=q+1
+ end
+ for i=1:10
+ //for values after decimal that should be converted to octal//
+ d=d*8
+ q=floor(d)
+ s=s+q/(10^i);
+ d=d-q
+ end
+k=b+s;
+disp('the octal equivalent of the given decimal number is')
+disp(k);//displaying the result//
diff --git a/1238/CH1/EX1.2/2.sce b/1238/CH1/EX1.2/2.sce new file mode 100755 index 000000000..b58187ae4 --- /dev/null +++ b/1238/CH1/EX1.2/2.sce @@ -0,0 +1,53 @@ +//binary to decimal conversion//
+//example 2//
+clc
+//clears the command window//
+clear
+// clears //
+p =1;
+// initialising //
+q =1;
+z =0;
+b =0;
+w =0;
+f =0;
+//bin= input ( Enter the binary no to be converted to its decimal equivalent : )
+//accepting the binary input from user//
+bin =11.0111;
+d =modulo(bin ,1);
+//separating the decimal part and the integer part//
+d=d *10^10;
+a = floor (bin) ;
+//removing the decimal part//
+while (a >0)
+//Loop to take the binary bits of integer into a matrix //
+r = modulo (a ,10) ;
+b(1,q) = r ;
+a=a /10;
+a= floor ( a ) ;
+q=q +1;
+end
+for m =1: q -1
+// multipliying the bits of integer position values and adding//
+c=m -1;
+f=f+b(1,m) *(2^ c);
+end
+while (d >0)
+// Loop to take the binary bits of decimal into a matrix//
+e = modulo (d ,2)
+w(1 ,p)=e
+d = d /10;
+d= floor (d)
+p=p +1;
+end
+for n =1: p -1
+// multipliying the bits of decimal with their position values and adding//
+z=z+w(1 ,n)*(0.5) ^(11 -n);
+end
+z = z *10000;
+//rounding of to 4 decimal values//
+z= round (z);
+z = z /10000;
+x=f+z;
+disp ( 'The Decimal equivalent of the binary number given is ');
+disp (x);//result is displayed//
diff --git a/1238/CH1/EX1.20.a/20_a.sce b/1238/CH1/EX1.20.a/20_a.sce new file mode 100755 index 000000000..10d8bec3f --- /dev/null +++ b/1238/CH1/EX1.20.a/20_a.sce @@ -0,0 +1,13 @@ +//decimal to signed binary number//
+//example 20.a//
+//decimal to signed binary number system//
+clc
+//clears the command window//
+clear
+//clears//
+x=+29
+a=dec2bin(x,6)
+//decimal to binary conversion//
+disp('the answer is')
+disp(a)
+//since the number is positive it starts with a 0//
diff --git a/1238/CH1/EX1.20.b/20_b.sce b/1238/CH1/EX1.20.b/20_b.sce new file mode 100755 index 000000000..b891d6cd1 --- /dev/null +++ b/1238/CH1/EX1.20.b/20_b.sce @@ -0,0 +1,14 @@ +//decimal to signed binary number//
+//example 20.b//
+clc
+//clears the command window//
+clear
+//clears//
+//decimal to signed binary number system//
+x=-29
+a=dec2bin(-x)
+//decimal to binary conversion//
+a=dec2bin(-x+bin2dec('100000'))
+disp('the answer is:')
+disp(a)
+//since the number is negative it starts with a 1//
diff --git a/1238/CH1/EX1.20.c/20_c.sce b/1238/CH1/EX1.20.c/20_c.sce new file mode 100755 index 000000000..18ee715ed --- /dev/null +++ b/1238/CH1/EX1.20.c/20_c.sce @@ -0,0 +1,14 @@ +//decimal to signed binary number//
+//example 20.c//
+clc
+//clears the command window//
+clear
+//clears//
+//decimal to signed binary number system//
+x=-19
+a=dec2bin(-x)
+//decimal to binary conversion//
+a=dec2bin(-x+bin2dec('100000'))
+disp('the answer is:')
+disp(a)
+//since the number is negative it starts with a 1,msb indicates the sign//
diff --git a/1238/CH1/EX1.21.a/21_a.sce b/1238/CH1/EX1.21.a/21_a.sce new file mode 100755 index 000000000..7cabb8b83 --- /dev/null +++ b/1238/CH1/EX1.21.a/21_a.sce @@ -0,0 +1,16 @@ +//subtraction using 1's complement//
+//Example 21.a//
+//subtraction in one's complement using 8 bits//
+clc
+//clears the window//
+clear
+//clears all the existing variables//
+x='11001'
+y=bin2dec('11001')
+z=bin2dec('10110')
+c=(bitcmp(z,5));//finding 1's complement//
+a=y+c+1
+a=a-bin2dec('100000')
+a=dec2bin(a,5);//converting the result to binary equivalent//
+disp('the subtraction of two numbers give:')
+disp(a);//displaying the result//
diff --git a/1238/CH1/EX1.21.b/21_b.sce b/1238/CH1/EX1.21.b/21_b.sce new file mode 100755 index 000000000..a0dc2d115 --- /dev/null +++ b/1238/CH1/EX1.21.b/21_b.sce @@ -0,0 +1,16 @@ +//subtraction using 1's complement//
+//Example 21.b//
+//subtraction in one's complement using 8 bits//
+clc
+//clears the window//
+clear
+//clears all the existing variables//
+x='1011'
+y=bin2dec('1011')
+z=bin2dec('0101')
+c=(bitcmp(z,4));//finding 1's complement//
+a=y+c+1
+a=a-bin2dec('10000');
+a=dec2bin(a,4);//converting the result to binary equivalent//
+disp('the subtraction of two binary numbers give:')
+disp(a);//displaying the result//
diff --git a/1238/CH1/EX1.21.c/21_c.sce b/1238/CH1/EX1.21.c/21_c.sce new file mode 100755 index 000000000..f551d4a73 --- /dev/null +++ b/1238/CH1/EX1.21.c/21_c.sce @@ -0,0 +1,16 @@ +//subtraction using 1's complement//
+//Example 21.c//
+//subtraction in one's complement using 8 bits//
+clc
+//clears the window//
+clear
+//clears all the existing variables//
+x='11011'
+y=bin2dec('11011')
+z=bin2dec('11001')
+c=(bitcmp(z,5));//finding 1's complement//
+a=y+c+1
+a=a-bin2dec('100000');
+a=dec2bin(a);//converting the result to binary equivalent//
+disp('the subtraction of two binary numbers give:')
+disp(a);//displaying the result//
diff --git a/1238/CH1/EX1.21.d/21_d.sce b/1238/CH1/EX1.21.d/21_d.sce new file mode 100755 index 000000000..8fe00bc33 --- /dev/null +++ b/1238/CH1/EX1.21.d/21_d.sce @@ -0,0 +1,83 @@ +//subtraction using 1's complement//
+//example 21.d//
+clc
+//clears the command window//
+clear
+// clears //
+//converting first binary input to decimal//
+p =1;
+// initialising //
+q =1;
+z =0;
+b =0;
+w =0;
+f =0;
+//bin= input ( Enter the binary no to be converted to its decimal equivalent : )
+//accepting the first binary input from user//
+bin =10111.1;
+d =modulo(bin ,1);
+//separating the decimal part and the integer part//
+d=d *10^10;
+a =floor(bin) ;
+//removing the decimal part//
+while (a >0)
+//Loop to take the binary bits of integer into a matrix //
+r = modulo (a ,10) ;
+b(1,q) = r ;
+a=a /10;
+a= floor ( a ) ;
+q=q +1;
+end
+for m =1: q -1
+// multipliying the bits of integer position values and adding//
+c=m -1;
+f=f+b(1,m) *(2^ c);
+end
+while (d >0)
+// Loop to take the binary bits of decimal into a matrix//
+e = modulo (d ,2)
+w(1 ,p)=e
+d = d /10;
+d= floor (d)
+p=p +1;
+end
+for n =1: p -1
+// multipliying the bits of decimal with their position values and adding//
+z=z+w(1 ,n)*(0.5) ^(11 -n);
+end
+z = z *10000;
+//rounding of to 4 decimal values//
+z= round (z);
+z = z /10000;
+d1=f+z;
+//converting second binary input to its complement decimal number//
+p =1;
+// initialising //
+q =1;
+z =0;
+b =0;
+w =0;
+f =0;
+//accepting 2nd binary input//
+a=10011.1
+s=0;
+d=modulo(a,1);//separating integer and decimal part//
+//since complement of decimal part is 0,we do not consider it further//
+a=floor(a);//getting the integer part//
+ for i=1:5
+ x(i)=modulo(a,10)
+ if x(i)==1 then
+ x(i)=0
+ else
+ x(i)=1
+ end
+ s=s+(x(i)*(2^(i-1)))
+ a=a/10
+ a=floor(a)
+end
+d2=s;//assigning the equivalent decimal value to d2//
+r=d1+d2+.5;//adding 1 to the decimal equivalents to find the result//
+r=r-bin2dec('100000');
+r=dec2bin(r);//converting the result to binary equivalent//
+disp('the subtraction of two binary numbers give:')
+disp(r);//displaying the result//
diff --git a/1238/CH1/EX1.21.e/21_e.sce b/1238/CH1/EX1.21.e/21_e.sce new file mode 100755 index 000000000..b4e4e33ee --- /dev/null +++ b/1238/CH1/EX1.21.e/21_e.sce @@ -0,0 +1,109 @@ +//subtraction using 1's complement//
+//example 21.e//
+clc
+//clears the command window//
+clear
+// clears //
+//converting first binary input to decimal//
+p =1;
+// initialising //
+q =1;
+z =0;
+b =0;
+w =0;
+f =0;
+//bin= input ( Enter the binary no to be converted to its decimal equivalent : )
+//accepting the first binary input from user//
+bin =11011.00;
+d =modulo(bin ,1);
+//separating the decimal part and the integer part//
+d=d *10^10;
+a = floor (bin) ;
+//removing the decimal part//
+while (a >0)
+ //Loop to take the binary bits of integer into a matrix //
+ r = modulo (a ,10) ;
+ b(1,q) = r ;
+ a=a /10;
+ a= floor ( a ) ;
+ q=q +1;
+ end
+ for m =1: q -1
+ // multipliying the bits of integer position values and adding//
+ c=m -1;
+ f=f+b(1,m) *(2^ c);
+ end
+ while (d >0)
+ // Loop to take the binary bits of decimal into a matrix//
+ e = modulo (d ,2)
+ w(1 ,p)=e
+ d = d /10;
+ d= floor (d)
+ p=p +1;
+ end
+ for n =1: p -1
+ // multipliying the bits of decimal with their position values and adding//
+ z=z+w(1 ,n)*(0.5) ^(11 -n);
+ end
+z = z *10000;
+//rounding of to 4 decimal values//
+z= round (z);
+z = z /10000;
+d1=f+z;
+//converting second binary input to its complement decimal number//
+p =1;
+// initialising //
+q =1;
+z =0;
+b =0;
+w =0;
+f =0;
+a=10011.1
+s=0;
+d=modulo(a,1);//separating integer and decimal part//
+//since complement of decimal part is 0,we do not consider it further//
+a=floor(a);//getting the integer part//
+for i=1:5
+ x(i)=modulo(a,10)
+ if x(i)==1 then
+ x(i)=0
+ else
+ x(i)=1
+ end
+ s=s+(x(i)*(2^(i-1)))
+ a=a/10
+ a=floor(a)
+end
+d2=s;//assigning the equivalent decimal value to d2//
+r=d1+d2+.25;//adding 1 to the decimal equivalents to find the result//
+disp(r)
+r=r-bin2dec('100000')
+q=0;
+b=0;
+s=0;
+//enter the decimal number to be converted//
+a=r;
+d=modulo(a,1);//separating decimal and integer part//
+a=floor(a);//removing decimal part//
+while (a>0)
+ //taking integer part into a matrix and converting to equivalent binary//
+ x=modulo(a,2)
+ b=b+(10^q)*x
+ a=a/2
+ a=floor(a)
+ q=q+1
+ end
+ for i=1:10
+ //for values after decimal that should be converted to binary//
+ d=d*2
+ q=floor(d)
+ s=s+q/(10^i);
+ if d>=1 then
+ d=d-1
+ end
+ end
+k=b+s;
+disp('the subtraction of two numbers give :')
+disp(k);//displaying the result//
+
+
diff --git a/1238/CH1/EX1.22.a/22_a.sce b/1238/CH1/EX1.22.a/22_a.sce new file mode 100755 index 000000000..026990246 --- /dev/null +++ b/1238/CH1/EX1.22.a/22_a.sce @@ -0,0 +1,20 @@ +//subtraction using 2's complement//
+//Example 22.a//
+//subtraction using 2's complement//
+clc
+//clears the console//
+clear
+//clears all exisiting variables//
+a=bin2dec('11011')
+b=bin2dec('11001')
+x=bitcmp(b,5)
+//complement of the numbers//
+z=1
+u=x+z
+//1 is added to the complements//
+w=u+a
+w=w-bin2dec('100000')
+w=dec2bin(w);//coverting to binary form//
+disp('the subtraction of two binary numbers give:')
+disp(w);//displaying the result//
+
diff --git a/1238/CH1/EX1.22.b/22_b.sce b/1238/CH1/EX1.22.b/22_b.sce new file mode 100755 index 000000000..1f2f84089 --- /dev/null +++ b/1238/CH1/EX1.22.b/22_b.sce @@ -0,0 +1,20 @@ +//subtraction using 2's complement//
+//Example 22.b//
+//subtraction using 2's complement//
+clc
+//clears the console//
+clear
+//clears all exisiting variables//
+a=bin2dec('11011')
+b=bin2dec('01100')
+x=bitcmp(b,5)
+//complement of the numbers//
+z=1
+u=x+z
+//1 is added to the complements//
+w=u+a
+w=w-bin2dec('100000')
+w=dec2bin(w);//coverting to binary form//
+disp('the subtraction of two binary numbers give:')
+disp(w);//displaying the result//
+
diff --git a/1238/CH1/EX1.22.c/22_c.sce b/1238/CH1/EX1.22.c/22_c.sce new file mode 100755 index 000000000..e249de673 --- /dev/null +++ b/1238/CH1/EX1.22.c/22_c.sce @@ -0,0 +1,75 @@ +//subtraction using 2's complement//
+//example 22.c//
+clc
+//clears the command window//
+clear
+// clears //
+//converting first binary input to decimal//
+p =1;
+// initialising //
+q =1;
+z =0;
+b =0;
+w =0;
+f =0;
+//bin= input ( Enter the binary no to be converted to its decimal equivalent : )
+//accepting the first binary input from user//
+bin =0.01111;
+bin=bin*100000
+y=0;
+for i=1:4
+ x(i)=modulo(bin,10)
+ y=y+(x(i)/(2^(6-i)))
+ bin=bin/10
+ bin=floor(bin)
+end
+d1=y
+//converting second binary input to its complement decimal number//
+a=.01001
+a=a*100000
+s=0;
+for i=1:4
+ x(i)=modulo(a,10)
+ if x(i)==1 then
+ x(i)=0
+ else
+ x(i)=1
+ end
+ s=s+(x(i)/(2^(6-i)))
+ a=a/10
+ a=floor(a)
+end
+s=s+.5
+d2=s;//assigning the equivalent decimal value to d2//
+d2=d2+.03125;
+r=d1+d2;//result in decimal form//
+r=r-bin2dec('1')
+//converting to binary form//
+q=0;
+b=0;
+s=0;
+//enter the decimal number to be converted//
+a=r;
+d=modulo(a,1);//separating decimal and integer part//
+a=floor(a);//removing decimal part//
+while (a>0)
+//taking integer part into a matrix and converting to equivalent binary//
+ x=modulo(a,2)
+ b=b+(10^q)*x
+ a=a/2
+ a=floor(a)
+ q=q+1
+ end
+ for i=1:10
+ //for values after decimal that should be converted to binary//
+ d=d*2
+ q=floor(d)
+ s=s+q/(10^i);
+ if d>=1 then
+ d=d-1
+ end
+ end
+k=b+s;
+disp('the subtraction of two binary numbers give:')
+disp(k);//the result in binary form//
+
diff --git a/1238/CH1/EX1.22.d/22_d.sce b/1238/CH1/EX1.22.d/22_d.sce new file mode 100755 index 000000000..f7fe3351a --- /dev/null +++ b/1238/CH1/EX1.22.d/22_d.sce @@ -0,0 +1,102 @@ +//subtraction using 2's complement//
+//example 22.d//
+clc
+//clears the command window//
+clear
+// clears //
+//converting first binary input to decimal//
+p =1;
+// initialising //
+q =1;
+z =0;
+b =0;
+w =0;
+f =0;
+//bin= input ( Enter the binary no to be converted to its decimal equivalent : )
+//accepting the first binary input from user//
+bin =111.010;
+d =modulo(bin ,1);
+//separating the decimal part and the integer part//
+d=d *10^10;
+a = floor (bin) ;
+//removing the decimal part//
+while (a >0)
+//Loop to take the binary bits of integer into a matrix //
+r = modulo (a ,10) ;
+b(1,q) = r ;
+a=a /10;
+a= floor ( a ) ;
+q=q +1;
+end
+ for m =1: q -1
+ // multipliying the bits of integer position values and adding//
+ c=m -1;
+ f=f+b(1,m) *(2^ c);
+ end
+ while (d >0)
+ // Loop to take the binary bits of decimal into a matrix//
+ e = modulo (d ,2)
+ w(1 ,p)=e
+ d = d /10;
+ d= floor (d)
+ p=p +1;
+ end
+ for n =1: p -1
+ // multipliying the bits of decimal with their position values and adding//
+ z=z+w(1 ,n)*(0.5) ^(11 -n);
+ end
+z = z *10000;
+//rounding of to 4 decimal values//
+z= round (z);
+z = z /10000;
+d1=f+z;
+//converting second binary input to its complement decimal number//
+a=010.111;
+s=0;
+d=modulo(a,1);//separating integer and decimal part//
+//since complement of decimal part is 0,we do not consider it further//
+a=floor(a);//getting the integer part//
+for i=1:3
+ x(i)=modulo(a,10)
+ if x(i)==1 then
+ x(i)=0
+ else
+ x(i)=1
+ end
+ s=s+(x(i)*(2^(i-1)))
+ a=a/10
+ a=floor(a)
+end
+d2=s;//assigning the equivalent decimal value to d2//
+d2=d2+.125;//since decimal is upto three places//
+r=d1+d2;
+r=r-bin2dec('1000');//step to ignore the msb//
+//converting the result to its binary equivalent//
+q=0;
+b=0;
+s=0;
+//enter the decimal number to be converted//
+a=r;
+d=modulo(a,1);//separating decimal and integer part//
+a=floor(a);//removing decimal part//
+while (a>0)
+//taking integer part into a matrix and converting to equivalent binary//
+x=modulo(a,2)
+b=b+(10^q)*x
+a=a/2
+a=floor(a)
+q=q+1
+ end
+ for i=1:10
+ //for values after decimal that should be converted to binary//
+ d=d*2
+ q=floor(d)
+ s=s+q/(10^i);
+ if d>=1 then
+ d=d-1
+ end
+ end
+k=b+s;
+disp('the subtraction of two binary numbers give:')
+disp(k);//required result in binary form//
+
diff --git a/1238/CH1/EX1.22.e/22_e.sce b/1238/CH1/EX1.22.e/22_e.sce new file mode 100755 index 000000000..7d495ab74 --- /dev/null +++ b/1238/CH1/EX1.22.e/22_e.sce @@ -0,0 +1,101 @@ +//subtraction using 2's complement//
+//example 22.e//
+clc
+//clears the command window//
+clear
+// clears //
+//converting first binary input to decimal//
+p =1;
+// initialising //
+q =1;
+z =0;
+b =0;
+w =0;
+f =0;
+//bin= input ( Enter the binary no to be converted to its decimal equivalent : )
+//accepting the first binary input from user//
+bin =111.01;
+d =modulo(bin ,1);
+//separating the decimal part and the integer part//
+d=d *10^10;
+a = floor (bin) ;
+//removing the decimal part//
+ while (a >0)
+ //Loop to take the binary bits of integer into a matrix //
+ r = modulo (a ,10) ;
+ b(1,q) = r ;
+ a=a /10;
+ a= floor ( a ) ;
+ q=q +1;
+ end
+ for m =1: q -1
+ // multipliying the bits of integer position values and adding//
+ c=m -1;
+ f=f+b(1,m) *(2^ c);
+ end
+ while (d >0)
+ // Loop to take the binary bits of decimal into a matrix//
+ e = modulo (d ,2)
+ w(1 ,p)=e
+ d = d /10;
+ d= floor (d)
+ p=p +1;
+ end
+ for n =1: p -1
+ // multipliying the bits of decimal with their position values and adding//
+ z=z+w(1 ,n)*(0.5) ^(11 -n);
+ end
+z = z *10000;
+//rounding of to 4 decimal values//
+z= round (z);
+z = z /10000;
+d1=f+z;
+//converting second binary input to its complement decimal number//
+a=110.11;
+s=0;
+d=modulo(a,1);//separating integer and decimal part//
+//since complement of decimal part is 0,we do not consider it further//
+a=floor(a);//getting the integer part//
+ for i=1:3
+ x(i)=modulo(a,10)
+ if x(i)==1 then
+ x(i)=0
+ else
+ x(i)=1
+ end
+ s=s+(x(i)*(2^(i-1)))
+ a=a/10
+ a=floor(a)
+end
+d2=s;//assigning the equivalent decimal value to d2//
+d2=d2+.25;//since decimal is upto three places//
+r=d1+d2;
+r=r-bin2dec('1000');//step to ignore the msb//
+//converting the result to its binary equivalent//
+q=0;
+b=0;
+s=0;
+//enter the decimal number to be converted//
+a=r;
+d=modulo(a,1);//separating decimal and integer part//
+a=floor(a);//removing decimal part//
+while (a>0)
+//taking integer part into a matrix and converting to equivalent binary//
+x=modulo(a,2)
+b=b+(10^q)*x
+a=a/2
+a=floor(a)
+q=q+1
+ end
+ for i=1:10
+ //for values after decimal that should be converted to binary//
+ d=d*2
+ q=floor(d)
+ s=s+q/(10^i);
+ if d>=1 then
+ d=d-1
+ end
+ end
+k=b+s;
+disp('the subtraction of two binary numbers give:')
+disp(k);//required result in binary form//
diff --git a/1238/CH1/EX1.22.f/22_f.sce b/1238/CH1/EX1.22.f/22_f.sce new file mode 100755 index 000000000..437d6a421 --- /dev/null +++ b/1238/CH1/EX1.22.f/22_f.sce @@ -0,0 +1,101 @@ +//subtraction using 2's complement//
+//example 22.f//
+clc
+//clears the command window//
+clear
+// clears //
+//converting first binary input to decimal//
+p =1;
+// initialising //
+q =1;
+z =0;
+b =0;
+w =0;
+f =0;
+//bin= input ( Enter the binary no to be converted to its decimal equivalent : )
+//accepting the first binary input from user//
+bin =10111.1;
+d =modulo(bin ,1);
+//separating the decimal part and the integer part//
+d=d *10^10;
+a = floor (bin) ;
+//removing the decimal part//
+ while (a >0)
+ //Loop to take the binary bits of integer into a matrix //
+ r = modulo (a ,10) ;
+ b(1,q) = r ;
+ a=a /10;
+ a= floor ( a ) ;
+ q=q +1;
+ end
+ for m =1: q -1
+ // multipliying the bits of integer position values and adding//
+ c=m -1;
+ f=f+b(1,m) *(2^ c);
+ end
+ while (d >0)
+ // Loop to take the binary bits of decimal into a matrix//
+ e = modulo (d ,2)
+ w(1 ,p)=e
+ d = d /10;
+ d= floor (d)
+ p=p +1;
+ end
+ for n =1: p -1
+ // multipliying the bits of decimal with their position values and adding//
+ z=z+w(1 ,n)*(0.5) ^(11 -n);
+ end
+z = z *10000;
+//rounding of to 4 decimal values//
+z= round (z);
+z = z /10000;
+d1=f+z;
+//converting second binary input to its complement decimal number//
+a=10011.1;
+s=0;
+d=modulo(a,1);//separating integer and decimal part//
+//since complement of decimal part is 0,we do not consider it further//
+a=floor(a);//getting the integer part//
+ for i=1:5
+ x(i)=modulo(a,10)
+ if x(i)==1 then
+ x(i)=0
+ else
+ x(i)=1
+ end
+ s=s+(x(i)*(2^(i-1)))
+ a=a/10
+ a=floor(a)
+end
+d2=s;//assigning the equivalent decimal value to d2//
+d2=d2+.5;//since decimal is upto three places//
+r=d1+d2;
+r=r-bin2dec('100000');//step to ignore the msb//
+//converting the result to its binary equivalent//
+q=0;
+b=0;
+s=0;
+//enter the decimal number to be converted//
+a=r;
+d=modulo(a,1);//separating decimal and integer part//
+a=floor(a);//removing decimal part//
+while (a>0)
+//taking integer part into a matrix and converting to equivalent binary//
+x=modulo(a,2)
+b=b+(10^q)*x
+a=a/2
+a=floor(a)
+q=q+1
+ end
+ for i=1:10
+ //for values after decimal that should be converted to binary//
+ d=d*2
+ q=floor(d)
+ s=s+q/(10^i);
+ if d>=1 then
+ d=d-1
+ end
+ end
+k=b+s;
+disp('the subtraction of two binary numbers give:')
+disp(k);//required result in binary form//
diff --git a/1238/CH1/EX1.23.a/23_a.sce b/1238/CH1/EX1.23.a/23_a.sce new file mode 100755 index 000000000..9c093a3d4 --- /dev/null +++ b/1238/CH1/EX1.23.a/23_a.sce @@ -0,0 +1,37 @@ +//BCD to decimal conversion//
+//Example 23.a//
+//subtraction using 2's complement//
+clc
+//clears the console//
+clear
+//clears all exisiting variables//
+a=010000111001;//taking the BCD input//
+z=0;
+d=modulo(a,10000)
+ for j=1:4
+ y(j)=modulo(d,10)
+ z=z+(y(j)*(2^(j-1)))
+ d=d/10
+ d=floor(d)
+ end
+b=a/10000
+b=floor(b)
+c=modulo(b,10000)
+z1=0
+for j=1:2
+ y(j)=modulo(c,10)
+ z1=z1+(y(j)*(2^(j-1)))
+ c=c/10
+ c=floor(c)
+end
+e=b/10000
+e=floor(e)
+z2=0
+for j=1:3
+ y(j)=modulo(e,10)
+ z2=z2+(y(j)*(2^(j-1)))
+ e=e/10
+ e=floor(e)
+end
+r=z2*100+z1*10+z
+printf('the decimal equivalent of BCD code is=%d',r)
diff --git a/1238/CH1/EX1.23.b/23_b.sce b/1238/CH1/EX1.23.b/23_b.sce new file mode 100755 index 000000000..6bc1b9b3b --- /dev/null +++ b/1238/CH1/EX1.23.b/23_b.sce @@ -0,0 +1,47 @@ +//BCD to decimal conversion//
+//Example 23.b//
+//subtraction using 2's complement//
+clc
+//clears the console//
+clear
+//clears all exisiting variables//
+a=100001001111000;//taking the BCD input//
+z=0;
+d=modulo(a,10000)
+ for j=1:4
+ y(j)=modulo(d,10)
+ z=z+(y(j)*(2^(j-1)))
+ d=d/10
+ d=floor(d)
+ end
+b=a/10000
+b=floor(b)
+z1=0
+c=modulo(b,10000)
+for i=1:3
+ y(i)=modulo(c,10)
+ z1=z1+(y(i)*(2^(i-1)))
+ c=c/10
+ c=floor(c)
+end
+z2=0
+e=b/10000
+e=floor(e)
+f=modulo(e,10000)
+for i=1:2
+ y(i)=modulo(f,10)
+ z2=z2+(y(i)*(2^(i-1)))
+ f=f/10
+ f=floor(f)
+end
+g=e/10000
+g=floor(g)
+z3=0
+for i=1:3
+ y(i)=modulo(g,10)
+ z3=z3+(y(i)*(2^(i-1)))
+ g=g/10
+ g=floor(g)
+end
+r=z3*1000+z2*100+z1*10+z
+printf('the equivalent decimal number is=%d',r)
diff --git a/1238/CH1/EX1.24.a/24_a.sce b/1238/CH1/EX1.24.a/24_a.sce new file mode 100755 index 000000000..be89267e5 --- /dev/null +++ b/1238/CH1/EX1.24.a/24_a.sce @@ -0,0 +1,33 @@ +//binary to gray code//
+//Example 24.a//
+//binary to gray code//
+clc
+//clears the console//
+clear
+//clears all existing variables//
+a=110100
+for i=1:6
+ x(i)=modulo(a,10)
+ a=a/10
+ a=floor(a)
+end
+y(6)=x(6)
+k=5
+while(k>0)
+ if (bitand(x(k+1),x(k))==1) then
+ a=bitand(x(k+1),x(k))
+ y(k)=bitcmp(a,1)
+else
+ y(k)=bitor(x(k+1),x(k))
+ end
+ k=k-1
+end
+//display//
+z=0
+for i=1:6
+ z=z+y(i)*(10^(i-1))
+end
+disp(z)
+disp('equivalent gray code is displayed')
+
+
diff --git a/1238/CH1/EX1.24.b/24_b.sce b/1238/CH1/EX1.24.b/24_b.sce new file mode 100755 index 000000000..485b7d1dd --- /dev/null +++ b/1238/CH1/EX1.24.b/24_b.sce @@ -0,0 +1,31 @@ +//binary to gray code//
+//Example 24.b//
+//binary to gray code//
+clc
+//clears the console//
+clear
+//clears all existing variables//
+a=101101
+for i=1:6
+ x(i)=modulo(a,10)
+ a=a/10
+ a=floor(a)
+end
+y(6)=x(6)
+k=5
+while(k>0)
+ if (bitand(x(k+1),x(k))==1) then
+ a=bitand(x(k+1),x(k))
+ y(k)=bitcmp(a,1)
+else
+ y(k)=bitor(x(k+1),x(k))
+ end
+ k=k-1
+end
+//display//
+z=0
+for i=1:6
+ z=z+y(i)*(10^(i-1))
+end
+disp(z)
+disp('equivalent gray code is displayed')
diff --git a/1238/CH1/EX1.24.c/24_c.sce b/1238/CH1/EX1.24.c/24_c.sce new file mode 100755 index 000000000..99dad651e --- /dev/null +++ b/1238/CH1/EX1.24.c/24_c.sce @@ -0,0 +1,31 @@ +//binary to gray code//
+//Example 24.c//
+//binary to gray code//
+clc
+//clears the console//
+clear
+//clears all existing variables//
+a=1110010
+for i=1:7
+ x(i)=modulo(a,10)
+ a=a/10
+ a=floor(a)
+end
+y(7)=x(7)
+k=6
+while(k>0)
+ if (bitand(x(k+1),x(k))==1) then
+ a=bitand(x(k+1),x(k))
+ y(k)=bitcmp(a,1)
+else
+ y(k)=bitor(x(k+1),x(k))
+ end
+ k=k-1
+end
+//display//
+z=0
+for i=1:7
+ z=z+y(i)*(10^(i-1))
+end
+disp(z)
+disp('equivalent gray code is displayed')
diff --git a/1238/CH1/EX1.25.a/25_a.sce b/1238/CH1/EX1.25.a/25_a.sce new file mode 100755 index 000000000..212a8fd5c --- /dev/null +++ b/1238/CH1/EX1.25.a/25_a.sce @@ -0,0 +1,18 @@ +//subtraction using 1's complement//
+//Example 25.a//
+//subtraction in one's complement //
+clc
+//clears the window//
+clear
+//clears all the existing variables//
+x='1011101'
+y=bin2dec('1011101')
+z=bin2dec('1101100')
+c=bitcmp(z,7);//finding 1's complement//
+a=y+c+1
+a=dec2bin(a-(bin2dec('1000000')))
+//binary conversion//
+disp('binary form of the number obtained by adding 1011101 to -1101100')
+disp(a)
+//result is displayed//
+
diff --git a/1238/CH1/EX1.25.b/25_b.sce b/1238/CH1/EX1.25.b/25_b.sce new file mode 100755 index 000000000..cf7479cec --- /dev/null +++ b/1238/CH1/EX1.25.b/25_b.sce @@ -0,0 +1,31 @@ +//gray code to binary conversion//
+//Example 25.b//
+//gray code to binary//
+clc
+//clears the console//
+clear
+//clears all existing variables//
+a=1011010111001
+for i=1:13
+ x(i)=modulo(a,10)
+ a=a/10
+ a=floor(a)
+end
+y(13)=x(13)
+k=12
+while(k>0)
+ if (bitand(y(k+1),x(k))==1) then
+ a=bitand(y(k+1),x(k))
+ y(k)=bitcmp(a,1)
+else
+ y(k)=bitor(y(k+1),x(k))
+ end
+ k=k-1
+end
+z=0
+for i=1:13
+ z=z+y(i)*(10^(i-1))
+end
+disp(z)
+disp('equivalent binary code is displayed')
+
diff --git a/1238/CH1/EX1.25.c/25_c.sce b/1238/CH1/EX1.25.c/25_c.sce new file mode 100755 index 000000000..9e739c7a1 --- /dev/null +++ b/1238/CH1/EX1.25.c/25_c.sce @@ -0,0 +1,15 @@ +//decimal to BCD conversion//
+//example 25.c//
+clc
+//clears the command window//
+clear
+//clears//
+a=63547;//input in decimal//
+for i=1:5
+ x(i)=modulo(a,10)
+ a=a/10
+ a=floor(a)
+end
+x=strcat(dec2bin(x(5),4)+dec2bin(x(4),4)+dec2bin(x(3),4)+dec2bin(x(2),4)+dec2bin(x(1),4))
+disp('required BCD code is displayed')
+disp(x)
diff --git a/1238/CH1/EX1.25.d/25_d.sce b/1238/CH1/EX1.25.d/25_d.sce new file mode 100755 index 000000000..a81350ae6 --- /dev/null +++ b/1238/CH1/EX1.25.d/25_d.sce @@ -0,0 +1,20 @@ +//subtraction using 1's complement//
+//Example 25.d//
+//subtraction in one's complement//
+clc
+//clears the window//
+clear
+//clears all the existing variables//
+x=85
+y=32
+c=bitcmp(y,7);//finding 1's complement//
+a=x+c+1
+a=a-bin2dec('10000000')
+res=dec2bin(a,7)
+//binary conversion//
+disp('binary form of the number obtained by adding 85 to -32')
+disp(res)
+//result is displayed//
+
+
+
diff --git a/1238/CH1/EX1.26/26.sce b/1238/CH1/EX1.26/26.sce new file mode 100755 index 000000000..e15f02699 --- /dev/null +++ b/1238/CH1/EX1.26/26.sce @@ -0,0 +1,37 @@ +//finding equivalent in decimal for five excess 3 code numbers//
+//example 26//
+clc
+//clears the command window//
+clear
+//clears//
+//first number in excess-3 code//
+x='1000'
+a=bin2dec('1000');//conversion to binary//
+y=a-3;//conversion to excess 3 code//
+disp('equivalent decimal number for first excess 3 code:')
+disp(y);//displaying result//
+//second number in excess-3 code//
+x='0011'
+a=bin2dec('0011');//conversion to binary//
+y=a-3;//conversion to excess 3 code//
+disp('equivalent decimal number for second excess 3 code:')
+disp(y);//displaying result//
+//third number in excess 3-code//
+x='0100'
+a=bin2dec('0100');//conversion to binary//
+y=a-3;//conversion to excess 3 code//
+disp('equivalent decimal number for third excess 3 code:')
+disp(y);//displaying result//
+//fourth number in excess 3-code//
+x='0101'
+a=bin2dec('0101');//conversion to binary//
+y=a-3;//conversion to excess 3 code//
+disp('equivalent decimal number for fourth excess 3 code:')
+disp(y);//displaying result//
+//fifth number in excess 3-code//
+x='0111'
+a=bin2dec('0111');//conversion to binary//
+y=a-3;//conversion to excess 3 code//
+disp('equivalent decimal number for fifth excess 3 code:')
+disp(y);//displaying result//
+
diff --git a/1238/CH1/EX1.27.a/27_a.sce b/1238/CH1/EX1.27.a/27_a.sce new file mode 100755 index 000000000..1ad211f4e --- /dev/null +++ b/1238/CH1/EX1.27.a/27_a.sce @@ -0,0 +1,30 @@ +//gray code to binary conversion//
+//Example 27.a//
+//gray code to binary//
+clc
+//clears the console//
+clear
+//clears all existing variables//
+a=101110
+for i=1:6
+ x(i)=modulo(a,10)
+ a=a/10
+ a=floor(a)
+end
+y(6)=x(6)
+k=5
+while(k>0)
+ if (bitand(y(k+1),x(k))==1) then
+ a=bitand(y(k+1),x(k))
+ y(k)=bitcmp(a,1)
+else
+ y(k)=bitor(y(k+1),x(k))
+ end
+ k=k-1
+end
+z=0
+for i=1:6
+ z=z+y(i)*(10^(i-1))
+end
+disp(z)
+disp('equivalent binary code is displayed')
diff --git a/1238/CH1/EX1.27.b/27_b.sce b/1238/CH1/EX1.27.b/27_b.sce new file mode 100755 index 000000000..faa32ec1b --- /dev/null +++ b/1238/CH1/EX1.27.b/27_b.sce @@ -0,0 +1,30 @@ +//gray code to binary conversion//
+//Example 27.b//
+//gray code to binary//
+clc
+//clears the console//
+clear
+//clears all existing variables//
+a=111011
+for i=1:6
+ x(i)=modulo(a,10)
+ a=a/10
+ a=floor(a)
+end
+y(6)=x(6)
+k=5
+while(k>0)
+ if (bitand(y(k+1),x(k))==1) then
+ a=bitand(y(k+1),x(k))
+ y(k)=bitcmp(a,1)
+else
+ y(k)=bitor(y(k+1),x(k))
+ end
+ k=k-1
+end
+z=0
+for i=1:6
+ z=z+y(i)*(10^(i-1))
+end
+disp(z)
+disp('equivalent binary code is displayed')
diff --git a/1238/CH1/EX1.27.c/27_c.sce b/1238/CH1/EX1.27.c/27_c.sce new file mode 100755 index 000000000..b3639e9b6 --- /dev/null +++ b/1238/CH1/EX1.27.c/27_c.sce @@ -0,0 +1,30 @@ +//gray code to binary conversion//
+//Example 27.c//
+//gray code to binary//
+clc
+//clears the console//
+clear
+//clears all existing variables//
+a=1101110
+for i=1:7
+ x(i)=modulo(a,10)
+ a=a/10
+ a=floor(a)
+end
+y(7)=x(7)
+k=6
+while(k>0)
+ if (bitand(y(k+1),x(k))==1) then
+ a=bitand(y(k+1),x(k))
+ y(k)=bitcmp(a,1)
+else
+ y(k)=bitor(y(k+1),x(k))
+ end
+ k=k-1
+end
+z=0
+for i=1:7
+ z=z+y(i)*(10^(i-1))
+end
+disp(z)
+disp('equivalent binary code is displayed')
diff --git a/1238/CH1/EX1.28.a/28_a.sce b/1238/CH1/EX1.28.a/28_a.sce new file mode 100755 index 000000000..6d5937477 --- /dev/null +++ b/1238/CH1/EX1.28.a/28_a.sce @@ -0,0 +1,53 @@ +//constructing an even parity 7 bit hamming code//
+//example 28.a//
+clc
+//clears the command window//
+clear
+//clears//
+z=0100;//input//
+a=0;b=0;c=0;d=0;
+//taking the input//
+for i=1:7
+ x(i)=0
+ if (i==5) then
+ x(i)=1
+ end
+end
+//establishing even parity at positions 1,3,5,7//
+for i=3:7
+ if (x(i)==1) then
+ a=a+1
+ end
+end
+d=modulo(a,2)
+if (d==1) then
+ x(1)=1
+end
+//establishing even parity at positions 2,3,6,7//
+for i=3:7
+ if (i==5) then
+ continue
+ end
+ if (x(i)==1) then
+ b=b+1
+ end
+end
+d=modulo(b,2)
+if (d==1) then
+ x(2)=1
+end
+//establishing even parity at positions 4,5,6,7//
+for i=5:7
+ if (x(i)==1) then
+ c=c+1
+ end
+end
+d=modulo(c,2)
+if (d==1) then
+ x(4)=1
+end
+//displaying the result//
+disp('the required hamming code is:')
+for i=1:7
+ printf('%d',x(i))
+end
diff --git a/1238/CH1/EX1.28.b/28_b.sce b/1238/CH1/EX1.28.b/28_b.sce new file mode 100755 index 000000000..f205d8d40 --- /dev/null +++ b/1238/CH1/EX1.28.b/28_b.sce @@ -0,0 +1,62 @@ +//constructing an even parity 7 bit hamming code//
+//example 28.b//
+clc
+//clears the command window//
+clear
+//clears//
+z=1110;//input//
+a=0;b=0;c=0;d=0;
+//taking the input//
+for i=1:7
+ x(i)=0
+ if (i==3) then
+ x(i)=1
+ end
+ if (i==5) then
+ x(i)=1
+ end
+ if (i==6) then
+ x(i)=1
+ end
+end
+//establishing even parity at positions 1,3,5,7//
+for i=3:7
+ if (i==6) then
+ continue
+ end
+ if (x(i)==1) then
+ a=a+1
+ end
+end
+d=modulo(a,2)
+if (d==1) then
+ x(1)=1
+end
+//establishing even parity at positions 2,3,6,7//
+for i=3:7
+ if (i==5) then
+ continue
+ end
+ if (x(i)==1) then
+ b=b+1
+ end
+end
+d=modulo(b,2)
+if (d==1) then
+ x(2)=1
+end
+//establishing even parity at positions 4,5,6,7//
+for i=5:7
+ if (x(i)==1) then
+ c=c+1
+ end
+end
+d=modulo(c,2)
+if (d==1) then
+ x(4)=1
+end
+//displaying the result//
+disp('the required hamming code is:')
+for i=1:7
+ printf('%d',x(i))
+end
diff --git a/1238/CH1/EX1.29/29.sce b/1238/CH1/EX1.29/29.sce new file mode 100755 index 000000000..15a031f46 --- /dev/null +++ b/1238/CH1/EX1.29/29.sce @@ -0,0 +1,78 @@ +//locating error in hamming code and correcting it//
+//example 29//
+clc
+//clears the command window//
+clear
+//clears//
+a=1111001
+ b=0;c=0;d=0;e=0;
+ for i=1:7
+ x(8-i)=modulo(a,10)
+ a=a/10
+ a=floor(a)
+end
+//checking even parity at positions 4,5,6,7//
+for i=4:7
+ if (x(i)==1) then
+ b=b+1
+ end
+end
+d=modulo(b,2)
+if (d==0) then
+ r1=0
+else
+ r1=1
+end
+//checking even parity at positions 2,3,6,7//
+for i=2:7
+ if (i==4) then
+ continue
+ end
+ if (i==5) then
+ continue
+ end
+ if (x(i)==1) then
+ c=c+1
+ end
+end
+d=modulo(c,2)
+if (d==0) then
+ r2=0
+else
+ r2=1
+end
+//checking even parity at positions 1,3,5,7//
+for i=1:7
+ if (i==2) then
+ continue
+ end
+ if (i==4) then
+ continue
+ end
+ if (i==6) then
+ continue
+ end
+ if (x(i)==1) then
+ e=e+1
+ end
+end
+d=modulo(e,2)
+if (d==0) then
+ r3=0
+else
+ r3=1
+end
+r=r1*(2^2)+r2*(2^1)+r3;//converting to equivalent decimal//
+printf('error occurs at position=%d\n',r)
+//bit position at which error occurs has to be changed//
+if (x(r)==1) then
+ x(r)=0
+else
+ x(r)=1
+end
+//displaying the correct hamming code//
+disp('the correct hamming code is:')
+for i=1:7
+ printf('%d',x(i))
+end
+
diff --git a/1238/CH1/EX1.3/3.sce b/1238/CH1/EX1.3/3.sce new file mode 100755 index 000000000..f166ade9d --- /dev/null +++ b/1238/CH1/EX1.3/3.sce @@ -0,0 +1,53 @@ +//binary to decimal conversion//
+//example 3//
+clc
+//clears the command window//
+clear
+// clears //
+p =1;
+// initialising //
+q =1;
+z =0;
+b =0;
+w =0;
+f =0;
+//bin= input ( Enter the binary no to be converted to its decimal equivalent : )
+//accepting the binary input from user//
+bin =1100.11;
+d =modulo(bin ,1);
+//separating the decimal part and the integer part//
+d=d *10^10;
+a = floor (bin) ;
+//removing the decimal part//
+while (a >0)
+//Loop to take the binary bits of integer into a matrix //
+r = modulo (a ,10) ;
+b(1,q) = r ;
+a=a /10;
+a= floor ( a ) ;
+q=q +1;
+end
+for m =1: q -1
+// multipliying the bits of integer position values and adding//
+c=m -1;
+f=f+b(1,m) *(2^ c);
+end
+while (d >0)
+// Loop to take the binary bits of decimal into a matrix//
+e = modulo (d ,2)
+w(1 ,p)=e
+d = d /10;
+d= floor (d)
+p=p +1;
+end
+for n =1: p -1
+// multipliying the bits of decimal with their position values and adding//
+z=z+w(1 ,n)*(0.5) ^(11 -n);
+end
+z = z *10000;
+//rounding of to 4 decimal values//
+z= round (z);
+z = z /10000;
+x=f+z;
+disp (x)
+//result is displayed//
diff --git a/1238/CH1/EX1.4/4.sce b/1238/CH1/EX1.4/4.sce new file mode 100755 index 000000000..86c00f551 --- /dev/null +++ b/1238/CH1/EX1.4/4.sce @@ -0,0 +1,36 @@ +//decimal to binary conversion//
+//example 4//
+clc
+//clears the command window//
+clear
+//clears//
+//decimal to binary conversion//
+q=0;
+b=0;
+s=0;
+//enter the decimal number to be converted//
+a=27/32;
+d=modulo(a,1);//separating decimal and integer part//
+a=floor(a);//removing decimal part//
+while (a>0)
+//taking integer part into a matrix and converting to equivalent binary//
+x=modulo(a,2)
+b=b+(10^q)*x
+a=a/2
+a=floor(a)
+q=q+1
+end
+for i=1:10
+//for values after decimal that should be converted to binary//
+d=d*2
+q=floor(d)
+s=s+q/(10^i);
+if d>=1 then
+ d=d-1
+ end
+ end
+k=b+s;
+disp('the binary equivalent of the given decimal number is')
+disp(k);//displaying the result//
+
+
diff --git a/1238/CH1/EX1.5/5.sce b/1238/CH1/EX1.5/5.sce new file mode 100755 index 000000000..9db6ceb66 --- /dev/null +++ b/1238/CH1/EX1.5/5.sce @@ -0,0 +1,11 @@ +//decimal to octal conversion//
+//example 5//
+clc
+//clears the command window//
+clear
+//clears//
+//decimal to octal conversion//
+x=1993
+a=dec2oct(x)
+disp('the number in octal form is:')
+disp(a)
diff --git a/1238/CH1/EX1.6/6.sce b/1238/CH1/EX1.6/6.sce new file mode 100755 index 000000000..4acd4d0ca --- /dev/null +++ b/1238/CH1/EX1.6/6.sce @@ -0,0 +1,11 @@ +//Octal to decimal conversion//
+//example 6//
+clc
+//clears the command window//
+clear
+//clears//
+//octal to decimal conversion//
+x='3711'
+a=oct2dec(x)
+disp('the number in decimal form :')
+disp(a)
diff --git a/1238/CH1/EX1.7/7.sce b/1238/CH1/EX1.7/7.sce new file mode 100755 index 000000000..4ddc8896f --- /dev/null +++ b/1238/CH1/EX1.7/7.sce @@ -0,0 +1,14 @@ +//binary to octal conversion//
+//example 7//
+clc
+//clears the control window//
+clear
+//clears//
+//binary to octal conversion//
+x='11111001001'
+a=bin2dec('11111001001')
+//binary to decimal conversion//
+z=dec2oct(a)
+//decimal to octal conversion//
+disp('the number in octal form:')
+disp(z)
diff --git a/1238/CH1/EX1.8.a/8_a.sce b/1238/CH1/EX1.8.a/8_a.sce new file mode 100755 index 000000000..14f4191af --- /dev/null +++ b/1238/CH1/EX1.8.a/8_a.sce @@ -0,0 +1,11 @@ +//decimal to binary conversion//
+//example 8.a//
+clc
+//clears command window //
+clear
+//clears//
+//decimal to binary conversion//
+x=1996
+a=dec2bin(1996)
+disp('the result in binary form is')
+disp(a)
diff --git a/1238/CH1/EX1.8.b/8_b.sce b/1238/CH1/EX1.8.b/8_b.sce new file mode 100755 index 000000000..ead54e22d --- /dev/null +++ b/1238/CH1/EX1.8.b/8_b.sce @@ -0,0 +1,10 @@ +//binary to decimal conversion//
+//example 8.b//
+clc
+//clears command window //
+clear
+//clears//
+x='11111001100'
+a=bin2dec('11111001100');//binary to decimal conversion//
+disp('the number in decimal form is:')
+disp(a);//result is displayed//
diff --git a/1238/CH1/EX1.9.a/9_a.sce b/1238/CH1/EX1.9.a/9_a.sce new file mode 100755 index 000000000..bd9956ece --- /dev/null +++ b/1238/CH1/EX1.9.a/9_a.sce @@ -0,0 +1,35 @@ +//decimal to binary conversion//
+//example 9.a//
+clc
+//clears the command window//
+clear
+//clears//
+//decimal to binary conversion//
+q=0;
+b=0;
+s=0;
+//enter the decimal number to be converted//
+a=274.1875;
+d=modulo(a,1);//separating decimal and integer part//
+a=floor(a);//removing decimal part//
+while (a>0)
+//taking integer part into a matrix and converting to equivalent binary//
+x=modulo(a,2)
+b=b+(10^q)*x
+a=a/2
+a=floor(a)
+q=q+1
+ end
+ for i=1:10
+ //for values after decimal that should be converted to binary//
+ d=d*2
+ q=floor(d)
+ s=s+q/(10^i);
+ if d>=1 then
+ d=d-1
+ end
+ end
+k=b+s;
+disp('the binary equivalent of the given decimal number is')
+disp(k);//displaying the result//
+
diff --git a/1238/CH1/EX1.9.b/9_b.sce b/1238/CH1/EX1.9.b/9_b.sce new file mode 100755 index 000000000..299ff260a --- /dev/null +++ b/1238/CH1/EX1.9.b/9_b.sce @@ -0,0 +1,34 @@ +//decimal to binary conversion//
+//example 9.b//
+clc
+//clears the command window//
+clear
+//clears//
+//decimal to binary conversion//
+q=0;
+b=0;
+s=0;
+//enter the decimal number to be converted//
+a=.65625;
+d=modulo(a,1);//separating decimal and integer part//
+a=floor(a);//removing decimal part//
+while (a>0)
+//taking integer part into a matrix and converting to equivalent binary//
+ x=modulo(a,2)
+ b=b+(10^q)*x
+ a=a/2
+ a=floor(a)
+ q=q+1
+ end
+ for i=1:10
+ //for values after decimal that should be converted to binary//
+ d=d*2
+ q=floor(d)
+ s=s+q/(10^i);
+ if d>=1 then
+ d=d-1
+ end
+ end
+k=b+s;
+disp('the binary equivalent of the given decimal number is:')
+disp(k);//displaying the result//
diff --git a/1238/CH1/EX1.9.c/9_c.sce b/1238/CH1/EX1.9.c/9_c.sce new file mode 100755 index 000000000..c8d78e3e6 --- /dev/null +++ b/1238/CH1/EX1.9.c/9_c.sce @@ -0,0 +1,12 @@ +//decimal to binary conversion//
+//example 9.c//
+clc
+//clears the command window//
+clear
+//clears//
+//decimal to binary conversion//
+a=dec2bin(624)
+disp('binary equivalent of decimal number:')
+disp(a)
+//answer in binary form//
+
diff --git a/1238/CH1/EX1.9.d/9_d.sce b/1238/CH1/EX1.9.d/9_d.sce new file mode 100755 index 000000000..6d789f263 --- /dev/null +++ b/1238/CH1/EX1.9.d/9_d.sce @@ -0,0 +1,8 @@ +//binary to decimal conversion//
+//example 9.d//
+clc
+//clears command window //
+clear
+//clears//
+a=bin2dec('11010');//binary to decimal conversion//
+printf('actual age is=%d years',a);//person's actual age is displayed//
diff --git a/1238/CH2/EX2.10.a/10_a.sce b/1238/CH2/EX2.10.a/10_a.sce new file mode 100755 index 000000000..ebe5f4325 --- /dev/null +++ b/1238/CH2/EX2.10.a/10_a.sce @@ -0,0 +1,13 @@ +//simplification of boolean expressions//
+//example 10.a//
+clc
+//clears the command window//
+clear
+//clears//
+//simplification of boolean expression//
+disp('given Y=(A+B)''.(A''+B'')''')
+disp('Y=(A''.B'').(A.B)');//applying De Morgan's law//
+disp('Y=AA''.BB''')
+disp('the simplified expression is:')
+disp('Y=0');//since x.x''=0//
+//simplified boolean expression//
diff --git a/1238/CH2/EX2.10.b/10_b.sce b/1238/CH2/EX2.10.b/10_b.sce new file mode 100755 index 000000000..ebbffe2a8 --- /dev/null +++ b/1238/CH2/EX2.10.b/10_b.sce @@ -0,0 +1,13 @@ +//simplification of boolean expressions//
+//example 10.b//
+clc
+//clears the command window//
+clear
+//clears//
+//simplification of boolean expression//
+disp('Y=ABC+A''B+ABC''')
+disp('Y=AB(C+C'')+A''B')
+disp('Y=B(A+A'')');//C+C''=1//
+disp('the simplified expression is:')
+disp('Y=B');//simplified expression//
+
diff --git a/1238/CH2/EX2.10.c/10_c.sce b/1238/CH2/EX2.10.c/10_c.sce new file mode 100755 index 000000000..0e96f8cd3 --- /dev/null +++ b/1238/CH2/EX2.10.c/10_c.sce @@ -0,0 +1,13 @@ +//simplification of boolean expressions//
+//example 10.c//
+clc
+//clears the command window//
+clear
+//clears//
+//simplification of boolean expression//
+disp('given Y=C(AB''+AB)+BC')
+disp('Y=CA(B''+B)+BC')
+disp('Y=CA+BC');//B+B''=1//
+disp('the simplified expression is:')
+disp('Y=C(A+B)')
+//simplified boolean expression//
diff --git a/1238/CH2/EX2.11/11.sce b/1238/CH2/EX2.11/11.sce new file mode 100755 index 000000000..6a2228bcf --- /dev/null +++ b/1238/CH2/EX2.11/11.sce @@ -0,0 +1,14 @@ +//simplification of boolean expressions//
+//example 11//
+clc
+//clears the command window//
+clear
+//clears//
+//simplification of boolean expression//
+disp('given Y=ABCD+ABCD''+A''BCD+A''BCD''')
+disp('Y=BC(AD+AD''+A''D+A''D'')')
+disp('Y=BC{A(D+D'')+A''(D+D'')}')
+disp('Y=BC(A.1+A''.1)')
+disp('BC(A+A'')')
+disp('the simplified expression is:')
+disp('Y=BC');//simplified boolean expression//
diff --git a/1238/CH2/EX2.13.a/13_a.sce b/1238/CH2/EX2.13.a/13_a.sce new file mode 100755 index 000000000..d294ec5ab --- /dev/null +++ b/1238/CH2/EX2.13.a/13_a.sce @@ -0,0 +1,16 @@ +//simplification of boolean expressions//
+//example 13.a//
+clc
+//clears the command window//
+clear
+//clears//
+disp('given Z=(AB''C''+AB''C+ABC+ABC'')(A+B)')
+disp('Z={}AB''(C+C'')+AB(C+C'')}(A+B)')
+disp('Z=(AB''+AB)(A+B)')
+disp('Z=A(B''+B)(A+B)')
+disp('Z=A.1.(A+B)')
+disp('Z=AA+AB')
+disp('Z=A+AB')
+disp('Z=A(1+B)')
+disp('the simplified expression is:')
+disp('A');//simplified boolean expression//
diff --git a/1238/CH2/EX2.13.b/13_b.sce b/1238/CH2/EX2.13.b/13_b.sce new file mode 100755 index 000000000..f5a0d1e18 --- /dev/null +++ b/1238/CH2/EX2.13.b/13_b.sce @@ -0,0 +1,22 @@ +//simplification of boolean expressions//
+//example 13.b//
+clc
+//clears the command window//
+clear
+//clears//
+disp('given A=P+P''QR''+(Q+R)''')
+disp('A=P+P''QR''+Q''.R''');//DE MORGAN'S LAW//
+disp('A=P+R''(P''Q+Q'')')
+disp('A=P+R''[P''Q+Q''(P+P'')]')
+disp('A=P+R''[P''(Q+Q'')+PQ'']')
+disp('A=P+R''[P''+PQ]')
+disp('A=P+R''{(P''+P).(P''+Q'')}')
+disp('A=P+R''(P''+Q'')')
+disp('A=P+P''R''+Q''R''')
+disp('A=(P+P'').(P''+R'')+Q''R''')
+disp('A=1.(P+R'')+Q''R''')
+disp('A=P+R''+Q''R''')
+disp('A=P+R''+Q''R''')
+disp('A=P+R''(1+Q'')')
+disp('the simplified expression is:')
+disp('A=P+R''')
diff --git a/1238/CH2/EX2.29/29.sce b/1238/CH2/EX2.29/29.sce new file mode 100755 index 000000000..ed93f3b80 --- /dev/null +++ b/1238/CH2/EX2.29/29.sce @@ -0,0 +1,10 @@ +//finding SOP//
+//example 29//
+clc
+//clears the command window//
+clear
+//clears//
+disp('f=summation(1,2,4,7)')
+disp('f=001+0101+100+111')
+disp('required SOP form:')
+disp('f=A''B''C+A''BC''+AB''C''+ABC');
diff --git a/1238/CH2/EX2.30/30.sce b/1238/CH2/EX2.30/30.sce new file mode 100755 index 000000000..96b71be0d --- /dev/null +++ b/1238/CH2/EX2.30/30.sce @@ -0,0 +1,9 @@ +//finding POS//
+//example 30//
+clc
+//clears the command window//
+clear
+//clears//
+disp('given f=product(0,3,5,6)')
+disp('this indicates (000)(011)(101)(110)')
+disp('f=(A+B+C)(A+B''+C'')(A''+B+C'')(A''+B''+C)');//required POS expression//
diff --git a/1238/CH2/EX2.31.a/31_a.sce b/1238/CH2/EX2.31.a/31_a.sce new file mode 100755 index 000000000..be0fe9b7b --- /dev/null +++ b/1238/CH2/EX2.31.a/31_a.sce @@ -0,0 +1,17 @@ +//conversion to canonical SOP//
+//example 31.a//
+clc
+//clears the command window//
+clear
+//clears//
+//conversion to canonical SOP//
+disp('given Y=AB+A''B''+AC+A''C''')
+disp('since x+x''=1,we get')
+disp('Y=AB(C+C'')+A''B''(C+C'')+AC(B+B'')+A''C''(B+B'')')
+disp('Y=ABC+ABC''+A''B''C+A''B''C''+ACB''+ACB''+A''C''B+A''C''B''')
+disp('since ABC and A''B''C'' appear twice,we write them once')
+disp('Y=ABC+ABC''+A''B''C+A''B''C''+AB''C+A''BC''')
+disp('the required SOP expression')
+disp('Y=111+110+001+000+101+010')
+disp('hence the required entries will be at the positions 0,1,2,5,6,7')
+disp('f=summation(0,1,2,5,6,7)')
diff --git a/1238/CH2/EX2.31.b/31_b.sce b/1238/CH2/EX2.31.b/31_b.sce new file mode 100755 index 000000000..4ae6ccf26 --- /dev/null +++ b/1238/CH2/EX2.31.b/31_b.sce @@ -0,0 +1,15 @@ +//conversion to canonical POS//
+//example 31.b//
+clc
+//clears the command window//
+clear
+//clears//
+//conversion to canonical POS//
+disp('given Y=AB+A''B''+AC+A''C''')
+disp('we use the complement of the previous example')
+disp('the entries will be at 3,4 i.e. 011,100 positions')
+disp('Y=A''BC+AB''C''')
+disp('Y=(A''BC.AB''C'')''')
+//de morgan's theorem//
+disp('Y=(A+B''+C'').(A''+B+C)')
+disp('the required POS expression')
diff --git a/1238/CH2/EX2.32/32.sce b/1238/CH2/EX2.32/32.sce new file mode 100755 index 000000000..e61425db6 --- /dev/null +++ b/1238/CH2/EX2.32/32.sce @@ -0,0 +1,23 @@ +//finding SOP and POS//
+//example 32//
+clc
+//clears the command window//
+clear
+//clears//
+disp('given f=A''.(B+C'')')
+disp('f=(A''+BB''+CC'')(B+C''+AA'')')
+disp('f=[(A''+B)(A''+B'')+CC''][(B+C''+A)(B+C''+A'')]')
+disp('f=[C+(A''+B)(A''+B'')][C''+(A''+B)(A''+B)][(A+B+C'')(A''+B+C'')')
+disp('f=(C+A''+B)(C+A''+B'')(C''+A''+B)(C''+A''+B'')(A+B+C'')(A''+B+C)')
+disp('f=(A''+B+C)(A''+B''+C'')(A''+B+C'')(A''+B''+C'')(A+B+C'')')
+disp('f=(100)(110)(101)(111)(001)')
+disp('required POS form is:')
+disp('f=product(1,4,5,6,7)');//required POS form//
+disp('f=A''(B+C'')')
+disp('f=A''B+A''C'')')
+disp('f=A''B(C+C'')+A''C''(B+B'')')
+disp('f=A''BC+A''BC''+A''BC''+A''B''C''')
+disp('f=011+010+000')
+disp('required SOP form is:')
+disp('f=summation(0,2,3)');//required SOP form//
+
diff --git a/1238/CH2/EX2.33/33.sce b/1238/CH2/EX2.33/33.sce new file mode 100755 index 000000000..43f26eed8 --- /dev/null +++ b/1238/CH2/EX2.33/33.sce @@ -0,0 +1,20 @@ +//finding SOP and POS//
+//example 33//
+clc
+//clears the command window//
+clear
+//clears//
+disp('given f=B''C')
+disp('f=(B''+AA''+CC'')(C+AA''+BB'')')
+disp('f=((B''+A)(B''+A'')+CC'')((C+A)(C+A'')+BB'')')
+disp('f=[C+(B''+A)(B''+A'')][C''+(B''+A)(B''+A'')][B+(C+A)(C+A'')][B''+(C+A)+(C+A'')]');//using distributive property//
+disp('f=(A+B''+C)(A''+B''+C)(A+B''+C'')(A''+B''+C'')(A+B+C)(A''+B+C)');//using distributive property and retaining repeated factors only once//
+disp('f=(010)(110)(011)(111)(000)(100)')
+disp('required POS form:')
+disp('f=product(0,2,3,4,6,7)')
+//finding SOP//
+disp('f=(A+A'').B''C')
+disp('f=AB''C+A''BC')
+disp('f=101+001')
+disp('required SOP form:')
+disp('f=summation(5,1)')
diff --git a/1238/CH2/EX2.34/34.sce b/1238/CH2/EX2.34/34.sce new file mode 100755 index 000000000..227035b52 --- /dev/null +++ b/1238/CH2/EX2.34/34.sce @@ -0,0 +1,17 @@ +//finding maxterms and minterms//
+//example 34//
+clc
+//clears the command window//
+clear
+//clears//
+//finding minterms and maxterms//
+disp('given Y=AC''+A''C')
+disp('Y=A''C(B+B'')+AC''(B+B'')')
+disp('Y=A''CB+A''CB''+AC''B+AC''B''')
+disp('these are the required minterms')
+disp('the minterms indicate the positions 1,3,4,6')
+disp('the maxterms indicate the positions 0,2,5,7')
+//complementary of minterms//
+disp('Y=(A+B+C)(A+B''+C)+(A''+B+C'')(A''+B''+C'')')
+disp('these are the required maxterms')
+
diff --git a/1238/CH2/EX2.35/35.sce b/1238/CH2/EX2.35/35.sce new file mode 100755 index 000000000..56c3a622b --- /dev/null +++ b/1238/CH2/EX2.35/35.sce @@ -0,0 +1,11 @@ +//finding maxterms//
+//example 35//
+clc
+//clears the command window//
+clear
+//clears//
+disp('given f=product(0,3,5,6)')
+disp('f=(000)(011)(101)(110)')
+disp('required maxterms:')
+disp('f=(A+B+C)(A+B''+C'')(A''+B+C'')(A''+B''+C)')
+
diff --git a/1238/CH2/EX2.36/36.sce b/1238/CH2/EX2.36/36.sce new file mode 100755 index 000000000..44941c145 --- /dev/null +++ b/1238/CH2/EX2.36/36.sce @@ -0,0 +1,11 @@ +//finding required data//
+//example 36//
+clc
+//clears the command window//
+clear
+//clears//
+disp('f=A''B''C+A''BC''+AB''C+ABC''');//since f is 1 at positions 1,2,5,6;this is the required SOP expression//
+disp('f=(A+B+C)(A+B''+C'')(A''+B+C)(A''+B''+C'')');//since f is 0 at 0,3,4,7;this is the required POS expression//
+disp('sum of minterms=summation(1,2,5,6)')
+disp('product of maxterms=product(0,3,4,7)')
+
diff --git a/1238/CH2/EX2.37/37.sce b/1238/CH2/EX2.37/37.sce new file mode 100755 index 000000000..66111c9ef --- /dev/null +++ b/1238/CH2/EX2.37/37.sce @@ -0,0 +1,12 @@ +//finding SOP//
+//example 37//
+clc
+//clears the command window//
+clear
+//clears//
+disp('given f=AC')
+disp('f=AC(B+B'')(D+D'')')
+disp('f=ACBD+ACBD''+ACB''D+ACB''D''');//required sum of minterms//
+disp('f=1111+1110+1011+1010')
+disp('required SOP form:')
+disp('f=summation(10,11,14,15)')
diff --git a/1238/CH2/EX2.38/38.sce b/1238/CH2/EX2.38/38.sce new file mode 100755 index 000000000..688ce7993 --- /dev/null +++ b/1238/CH2/EX2.38/38.sce @@ -0,0 +1,14 @@ +//sum of minterms and product of maxterms//
+//example 38//
+clc
+//clears the command window//
+clear
+//clears//
+disp('given f=AB+A''BC+C''D')
+disp('f=AB(C+C'')(D+D'')+AB''C(D+D'')+C''D(A+A'')(B+B'')')
+disp('required sum of minterms:')
+disp('f=ABCD+ABCD''+ABC''D+ABC''D''+AB''CD+AB''CD''+AB''C''D+A''BC''D+A''B''C''D')
+disp('f=summation(1,5,9,10,11,12,13,14,15')
+disp('therefore f=product(0,2,3,4,6,7,8)')
+disp('required product of maxterms:')
+disp('f=(A+B+C+D)(A+B+C''+D)(A+B+C''+D'')(A+B+C''+D'')(A+B''+C+D)(A+B''+C''+D)(A+B''+C''+D'')(A''+B+C+D)')
diff --git a/1238/CH2/EX2.8.a/8_a.sce b/1238/CH2/EX2.8.a/8_a.sce new file mode 100755 index 000000000..17ddd3b13 --- /dev/null +++ b/1238/CH2/EX2.8.a/8_a.sce @@ -0,0 +1,16 @@ +//simplification of boolean expression//
+//example 8.a//
+clc
+//clears the command window//
+clear
+//clears//
+disp('given Y=AB+AB''C(B''C''+C)+A''C''')
+disp('Y=AB+AB''B''CC''+AB''CC+A''C''');//ON MULTIPLICATION//
+disp('Y=AB+AB''C+A''+C''');//CC''=0//
+disp('Y=C''+AB+(A+A'')(A''+B''C)')
+disp('Y=C''+AB+1.(A''+B''C)')
+disp('Y=A''+A.B+C''+B''C')
+disp('Y=(A''+A).(A''+B)+(C''+B'').(C''+C)')
+disp('Y=1.(A''+B)+(C''+B'').1')
+disp('the simplified expression is:')
+disp('Y=A''+B+C''+B''');//required simplified expression//
diff --git a/1238/CH2/EX2.8.b/8_b.sce b/1238/CH2/EX2.8.b/8_b.sce new file mode 100755 index 000000000..e4d964e52 --- /dev/null +++ b/1238/CH2/EX2.8.b/8_b.sce @@ -0,0 +1,13 @@ +//simplification of boolean expression//
+//example 8.b//
+clc
+//clears the command window//
+clear
+//clears//
+disp('given Y=A''BC''+A''BC+AB''C''+ABC')
+disp('Y=A''BC''+A''BC+A''BC+AB''C''+ABC')
+disp('Y=A''B(C+C'')+A''BC+AB''C+AB''C''')
+disp('Y=A''B.1+BC(A+A'')+AB''C''');//C+C''=1//
+disp('Y=A''B+BC+AB''C''');//A+A''=1//
+disp('the simplified expression is:')
+disp('Y=B.(A''+C)+AB''C''');//required simplified expression//
diff --git a/1238/CH2/EX2.9.a/9_a.sce b/1238/CH2/EX2.9.a/9_a.sce new file mode 100755 index 000000000..4ef0d4218 --- /dev/null +++ b/1238/CH2/EX2.9.a/9_a.sce @@ -0,0 +1,15 @@ +//simplification of boolean expression//
+//example 9.a//
+clc
+//clears the command window//
+clear
+//clears//
+//simplification of boolean expression//
+disp('given Y=ABC''D''+ABC''D+ABCD''+ABCD')
+disp('since D+D''=1,we get')
+disp('Y=ABC''(D+D'')+ABC(D''+D)')
+disp('Y=ABC''+ABC')
+disp('Y=AB(C+C'')')
+disp('the simplified expression is:')
+disp('Y=AB');//C+C'=1//
+//answer after simplification//
diff --git a/1238/CH2/EX2.9.b/9_b.sce b/1238/CH2/EX2.9.b/9_b.sce new file mode 100755 index 000000000..5b3ab6565 --- /dev/null +++ b/1238/CH2/EX2.9.b/9_b.sce @@ -0,0 +1,17 @@ +//simplification of boolean expression//
+//example 9.b//
+clc
+//clears the command window//
+clear
+//clears//
+//simplification of boolean expression//
+disp('given Y=AB+ABC''+A''BC+ABC')
+disp ('on simplification we get')
+disp('Y=AB+ABC''+A''BC+ABC+A''BC')
+disp('Y=AB+AB(C+C'')+BC(A+A'')')
+disp('since x+x''=1,we get')
+disp('Y=AB+AB+BC')
+disp('Y=AB+BC')
+disp('the simplified expression is:')
+disp('Y=B(A+C)')
+//answer after simplification//
diff --git a/1238/CH2/EX2.9.c/9_c.sce b/1238/CH2/EX2.9.c/9_c.sce new file mode 100755 index 000000000..a5a091ff6 --- /dev/null +++ b/1238/CH2/EX2.9.c/9_c.sce @@ -0,0 +1,16 @@ +//simplification of boolean expressions//
+//example 9.c//
+clc
+//clears the command window//
+clear
+//clears//
+//simplification of boolean expression//
+disp('given Y=AB(A''BC''+AB''C''+A''BC)')
+disp('on multiplication')
+disp('Y=ABA''BC''+ABAB''C''+ABA''BC')
+disp('Y=AA''.BC''+AB''.B''C''+AA''.BC')
+disp('since x.x''=0')
+disp('Y=0.BC''+A.0.C''+0.BC')
+disp('Y=0')
+//answer after simplification//
+
diff --git a/1238/CH3/EX3.1/1.sce b/1238/CH3/EX3.1/1.sce new file mode 100755 index 000000000..18936117b --- /dev/null +++ b/1238/CH3/EX3.1/1.sce @@ -0,0 +1,19 @@ +//finding required data//
+//example 1//
+clc
+//clears the command window//
+clear
+//clears//
+//finding time constant and time for capacitor to charge 90% of supplied voltage//
+R=10^6 ;//resistance in ohms//
+C=10^-5 ;//capacitance in farads//
+T=R*C
+printf('the time constant=%f seconds\n',T)
+//time constant is found out//
+v=90/100*10;//v=voltage at time t//
+V=10;//voltage in volts//
+//t=required time//
+disp('from the formula v=V*(1-exp(-t/(R*C))),we get the required time as:')
+t=-((R*C)*log(1-(v/V)))
+printf('required time to charge to 90 percent of the supplied voltage=%f seconds',t)
+//the result is t seconds//
diff --git a/1238/CH3/EX3.2/2.sce b/1238/CH3/EX3.2/2.sce new file mode 100755 index 000000000..25d73358c --- /dev/null +++ b/1238/CH3/EX3.2/2.sce @@ -0,0 +1,16 @@ +//finding minimum amplification//
+//example 2//
+clc
+//clears the command window//
+clear
+//clears//
+r=.04*10^-6
+//r is the rise time//
+disp('rise time=(2*v)/(2*%pi*f*V),hence')
+//f=frequency in hetrz;v=output voltage in volts;V=required maximum output voltage in volts//
+f=400*10^3
+v=6.28
+V=(2*v)/(r*2*%pi*f)
+Vin=12.5;//input voltage//
+a=V/Vin
+printf('minimum amplification required=%f ',a)
diff --git a/1238/CH3/EX3.3.a/3_a.sce b/1238/CH3/EX3.3.a/3_a.sce new file mode 100755 index 000000000..3b99d20e1 --- /dev/null +++ b/1238/CH3/EX3.3.a/3_a.sce @@ -0,0 +1,12 @@ +//finding clamping level voltage//
+//example 3.a//
+clc
+//clears the command window//
+clear
+//clears//
+//charge=voltage/time//
+disp('from equation ((V*4000*10^-6)/20)=((5-V)*4*10^-6)/(20*10^-3)),we get')
+//resistance=20kohm;V=clamping level voltage;charge=voltage*capacitance//
+V=5*(10^-6)
+printf('clamping level voltage=%f volt',V)
+//the answer is displayed//
diff --git a/1238/CH3/EX3.3.b/3_b.sce b/1238/CH3/EX3.3.b/3_b.sce new file mode 100755 index 000000000..8d9ea6472 --- /dev/null +++ b/1238/CH3/EX3.3.b/3_b.sce @@ -0,0 +1,12 @@ +//finding clamping level voltage//
+//example 3.b//
+clc
+//clears the command window//
+clear
+//clears//
+//charge=voltage/time//
+disp('from equation ((V*4*10^-6)/20)=((5-V)*4000*10^-6)/(20*10^-3)),we get')
+//resistance=20kohm;V=clamping level voltage;charge=voltage*capacitance//
+V=20/8
+printf('clamping level voltage=%f volt',V)
+//the answer is displayed//
diff --git a/1238/CH3/EX3.4/4.sce b/1238/CH3/EX3.4/4.sce new file mode 100755 index 000000000..57794766d --- /dev/null +++ b/1238/CH3/EX3.4/4.sce @@ -0,0 +1,23 @@ +//finding output voltage//
+//example 4//
+clc
+//clears the command window//
+clear
+//clears//
+V1=10;//voltage source amplitude//
+Rf=50;//forward rsistance//
+r1=50;//internal resistance//
+i=V1*Rf/(Rf+r1)
+//current through diode during positive half cycle//
+C=10^-6
+T=(Rf+r1)*C;//time constant during conduction//
+f=10*10^3
+T1=1/(2*f);//time duration during which input voltage is positive//
+t=50*10^-6;//given time//
+v=V1*(1-exp(-(t/T)));//voltage across capacitor after 50micro sec//
+Vo=((V1-v)*Rf)/(Rf+r1);//output voltage across diode//
+R=20*10^3;//resistance in series//
+T2=(r1+R)*C;//time constant of discharging circuit//
+V2=v*exp(-(t/T2));//voltage at the end of 50 micro sec//
+printf('output voltage=%f volt',V2)
+//result is displayed//
diff --git a/1238/CH3/EX3.6/6.sce b/1238/CH3/EX3.6/6.sce new file mode 100755 index 000000000..17ee41740 --- /dev/null +++ b/1238/CH3/EX3.6/6.sce @@ -0,0 +1,20 @@ +//finding load resistance and value of capacitor//
+//example 6//
+clc
+//clears the command window//
+clear
+//clears//
+Vo=15;//output voltage//
+t=10*10^-3;//time duration//
+tr=.05*10^-6;//rise time//
+Rs=100*10^3;//source resistance//
+C=50*10^-12;//output capacitance//
+S=.05;//sag allowed//
+//tr=.35/f2 where f2=upper cut off frequency//
+//also tr=2.2*R*C where R=load resistance//
+R=tr/(2.2*C)
+printf('resistance=%f ohms\n',R)
+//result is displayed//
+Cs=t/(Rs*S);//Cs=source capacitor//
+printf('capacitance=%f farad',Cs);//result is displayed//
+
diff --git a/1238/CH3/EX3.7/7.sce b/1238/CH3/EX3.7/7.sce new file mode 100755 index 000000000..22c257956 --- /dev/null +++ b/1238/CH3/EX3.7/7.sce @@ -0,0 +1,13 @@ +//finding peak voltage//
+//example 7//
+clc
+//clears the command window//
+clear
+//clears//
+T=250*10^-12;//time constant//
+t=.05*10^-6;
+Vo=100;//peak output voltage//
+Vi=(Vo*t)/T;//peak voltage of generator//
+printf('peak voltage=%f volt',Vi)
+//result is displayed//
+
diff --git a/1238/CH5/EX5.1/1.sce b/1238/CH5/EX5.1/1.sce new file mode 100755 index 000000000..f1e2c1639 --- /dev/null +++ b/1238/CH5/EX5.1/1.sce @@ -0,0 +1,10 @@ +//finding required time//
+//example 1//
+clc
+//clears the command window//
+clear
+//clears//
+R=10*10^3;//external resistance//
+C=0.1*10^-6;//timing capacitor//
+T=1.1*R*C;//time for which output remains high in monostable multivibrator using IC 555 timer//
+printf('required time=%f seconds',T);//result is displayed
diff --git a/1238/CH5/EX5.2/2.sce b/1238/CH5/EX5.2/2.sce new file mode 100755 index 000000000..ca143ac17 --- /dev/null +++ b/1238/CH5/EX5.2/2.sce @@ -0,0 +1,18 @@ +//calculating frequency and duty cycle//
+//example 2//
+clc
+//clears the command window//
+clear
+//clears//
+Ra=10*10^3
+Rb=10*10^3
+C=.001*10^-6
+T1=.693*(Ra+Rb)*C;//charging time constant//
+T2=.693*Rb*C;//discharging time constant//
+T=T1+T2;//total time//
+f=1/T;//frequency//
+printf('frequency=%f hertz\n',f);//result is displayed//
+D=T2/T;//duty cycle//
+D=D*100
+printf('duty cycle=%f percent',D)
+//result is displayed//
diff --git a/1238/CH5/EX5.3/3.sce b/1238/CH5/EX5.3/3.sce new file mode 100755 index 000000000..f5be5ecec --- /dev/null +++ b/1238/CH5/EX5.3/3.sce @@ -0,0 +1,17 @@ +//calculating frequency and duty cycle//
+//example 3//
+clc
+//clears the command window//
+clear
+//clears//
+Ra=6.8*10^3
+Rb=3.3*10^3
+C=.1*10^-6
+T1=.693*(Ra+Rb)*C;//charging time constant//
+T2= .693*Rb*C;//discharging time constant//
+T=T1+T2;//total time//
+f=1/T//frequency//
+printf('frequency=%f hertz\n',f);//result is displayed//
+D=T2/T;//duty cycle//
+D=D*100
+printf('duty cycle=%f percent',D);//result is displayed//
diff --git a/1238/CH8/EX8.1/8_1.sce b/1238/CH8/EX8.1/8_1.sce new file mode 100755 index 000000000..2deb93114 --- /dev/null +++ b/1238/CH8/EX8.1/8_1.sce @@ -0,0 +1,20 @@ +//finding binary equivalent weights//
+//example 1//
+clc
+//clears the command window//
+clear
+//clears//
+n=6;//no. of bits//
+LSB1=1/((2^6)-1)
+printf('weight of 1st lsb=%f\n',LSB1)
+LSB2=2*LSB1
+printf('weight of 2nd lsb=%f\n',LSB2)
+LSB3=4*LSB1
+printf('weight of 3rd lsb=%f\n',LSB3)
+LSB4=8*LSB1
+printf('weight of 4th lsb=%f\n',LSB4)
+LSB5=16*LSB1
+printf('weight of 5th lsb=%f\n',LSB5)
+MSB=32*LSB1
+printf('weight of msb=%f',MSB)
+//results are displayed//
diff --git a/1238/CH8/EX8.10/8_10.sce b/1238/CH8/EX8.10/8_10.sce new file mode 100755 index 000000000..b63d23970 --- /dev/null +++ b/1238/CH8/EX8.10/8_10.sce @@ -0,0 +1,25 @@ +//calculating required data//
+//example 10//
+clc
+//clears the command window//;
+clear
+//clears//
+S=10/10^3;//step size=weight of Ao in V//
+printf('step size=%f volt\n',S);//displaying step size//
+n=99;//no. of steps//
+Vmax=S*n;//maximum full scale output//
+printf('maximum full scale output=%f volt\n',Vmax);//displaying full scale output//
+R=S/Vmax*100;//percentage resolution//
+printf('percentage resolution=%f percent\n',R);//percentage resolution displayed//
+Ao=10/10^3
+Bo=20/10^3
+Co=40/10^3
+Do=80/10^3
+A1=100/10^3
+B1=200/10^3
+C1=400/10^3
+D1=800/10^3
+//weight in V of different inputs//
+//input for D1,C1,B1,A1 is 1101 and for Do,Co,Bo,Ao is 1011//
+V=D1+C1+A1+Do+Bo+Ao;//analog output voltage//
+printf('analog output voltage=%f volt',V);//result displayed//
diff --git a/1238/CH8/EX8.11/8_11.sce b/1238/CH8/EX8.11/8_11.sce new file mode 100755 index 000000000..d5ab675a9 --- /dev/null +++ b/1238/CH8/EX8.11/8_11.sce @@ -0,0 +1,20 @@ +//calculating output voltages//
+//example 11//
+clc
+//clears the command window//
+clear
+//clears//
+V=10;//high input voltage//
+VMSB=V/2;//output caused by MSB//
+VMSB2=V/4;//output caused by second MSB//
+VMSB3=V/8;//output caused by third MSB//
+VMSB4=V/16;//output caused by fourth MSB//
+VMSB5=V/32;//output caused by fifth MSB//
+VMSB6=V/64;//output caused by sixth MSB//
+printf('output caused by MSB=%f volt\n',VMSB)
+printf('output caused by second MSB=%f volt\n',VMSB2)
+printf('output caused by third MSB=%f volt\n',VMSB3)
+printf('output caused by fourth MSB=%f volt\n',VMSB4)
+printf('output caused by fifth MSB=%f volt\n',VMSB5)
+printf('output caused by sixth MSB=%f volt\n',VMSB6)
+//displaying the results//
diff --git a/1238/CH8/EX8.12/8_12.sce b/1238/CH8/EX8.12/8_12.sce new file mode 100755 index 000000000..7f77f76e4 --- /dev/null +++ b/1238/CH8/EX8.12/8_12.sce @@ -0,0 +1,16 @@ +//calculating required data//
+//example 12//
+clc
+//clears the command window//
+clear
+//clears//
+V=10;//high input voltage//
+//first part//
+//digital input is 101001//
+Vo=(10*2^0+0+0+10*2^3+0+10*2^5)/2^6;//output voltage//
+printf('output voltage for digital input 101001=%f volt\n',Vo);//displaying the result//
+//second part//
+//digital input is 110001//
+Vo1=(10*1+0+0+0+10*16+10*32)/64;//output voltage//
+printf('output voltage for input 110001=%f volt',Vo1);//displaying the result//
+
diff --git a/1238/CH8/EX8.13/8_13.sce b/1238/CH8/EX8.13/8_13.sce new file mode 100755 index 000000000..1927b95eb --- /dev/null +++ b/1238/CH8/EX8.13/8_13.sce @@ -0,0 +1,11 @@ +//calculating maximum full scale voltage//
+//example 13//
+clc
+//clears the command window//;
+clear
+//clears//
+//digital input is 11111111//
+//high input level=10V//
+Vo=10*(1+2+4+8+16+32+64+128)/256;//output voltage//
+printf('maximum full scale voltage=%f volt',Vo);//result displayed//
+
diff --git a/1238/CH8/EX8.14/8_14.sce b/1238/CH8/EX8.14/8_14.sce new file mode 100755 index 000000000..21cf9f56f --- /dev/null +++ b/1238/CH8/EX8.14/8_14.sce @@ -0,0 +1,24 @@ +//calculating required data//
+//example 14//
+clc
+//clears the command window//;
+clear
+//clears//
+//part i//
+//output high voltage=10V//
+VMSB1=1/2*10;//output caused by MSB//
+VMSB2=1/4*10;//output caused by second MSB//
+VMSB3=1/8*10;//output caused by third MSB//
+VLSB=1/16*10;//output caused by LSB//
+printf('output caused by msb=%f volt\n',VMSB1)
+printf('output caused by second msb=%f volt\n',VMSB2)
+printf('output caused by third msb=%f\n',VMSB3)
+printf('output caused by lsb=%f volt\n',VLSB)
+//displaying the results//
+//part ii//
+//input is 1011//
+V=1*VMSB1+0+1*VMSB3+1*VLSB;//output voltage//
+printf('output voltage at input 1011=%f volt\n',V);//displaying the result//
+//3rd part//
+Vo=VMSB1+VMSB2+VMSB3+VLSB;//full scale output voltage which occurs at 1111//
+printf('full scale output voltage=%f volt',Vo);//displaying the result//
diff --git a/1238/CH8/EX8.15/8_15.sce b/1238/CH8/EX8.15/8_15.sce new file mode 100755 index 000000000..c3ec619b9 --- /dev/null +++ b/1238/CH8/EX8.15/8_15.sce @@ -0,0 +1,12 @@ +//calculating no of bits//
+//example 15//
+clc
+//clears the command window//;
+clear
+//clears//
+disp('resolution=voltage corresponding to LSB')
+//weight of LSB=1/2^n,where n=no. of bits//
+disp('Voltage corresponding to LSB=1/2^n*10;which should be equal to resolution which is 10mv')
+disp('therefore 2^n=1000')
+disp('n=10');//nearest value of n which satisfies the equation is 10//
+//result is displayed//
diff --git a/1238/CH8/EX8.16/8_16.sce b/1238/CH8/EX8.16/8_16.sce new file mode 100755 index 000000000..9c9ef990a --- /dev/null +++ b/1238/CH8/EX8.16/8_16.sce @@ -0,0 +1,14 @@ +//calculating required data//
+//example 16//
+clc
+//clears the command window//;
+clear
+//clears//
+V=10;//full scale voltage
+W=1/2^12;//weight of LSB//
+R=V*W;//resolution//
+printf('resolution=%f volt\n',R);//result is displayed//
+S=R;//step size//
+R1=S/V*100;//percentage resolution//
+printf('percentage resolution=%f percent',R1)
+//result displayed//
diff --git a/1238/CH8/EX8.17/8_17.sce b/1238/CH8/EX8.17/8_17.sce new file mode 100755 index 000000000..f331fc01f --- /dev/null +++ b/1238/CH8/EX8.17/8_17.sce @@ -0,0 +1,20 @@ +//calculating required data//
+//example 17//
+clc
+//clears the command window//;
+clear
+//clears//
+//n=no. of bits//
+//resolution=1/2^n*5//
+R=5*10^-3;//resolution//
+V=5;//full scale output//
+n=log((5*10^-3)/5)/log(.5)
+//no. of bits//
+n=round(n)
+disp('no of bits:')
+disp(n);//result is displayed//
+S=1/2^n*5;//step size//
+R1=S/V*100;//percentage resolution//
+disp('percentage resolution:')
+disp(R1)
+//result is displayed//
diff --git a/1238/CH8/EX8.18/8_18.sce b/1238/CH8/EX8.18/8_18.sce new file mode 100755 index 000000000..d5ba93c8e --- /dev/null +++ b/1238/CH8/EX8.18/8_18.sce @@ -0,0 +1,15 @@ +//calculating conversion time//
+//example 18//
+clc
+//clears the command window//;
+clear
+//clears//
+T=1/(1000*10^3);//time for one clock cycle//
+disp(T)
+n=10;//no. of bits//
+t=(2^n-1)*T;//conversion time for 10 bit A/D converter//
+disp('conversion time for digital ramp A/D converter:')
+disp(t);//displaying result//
+t1=T*10;
+disp('conversion time for 10 bit successive approximation A/D converter:')
+disp(t1)
diff --git a/1238/CH8/EX8.19/8_19.sce b/1238/CH8/EX8.19/8_19.sce new file mode 100755 index 000000000..4921a4fd5 --- /dev/null +++ b/1238/CH8/EX8.19/8_19.sce @@ -0,0 +1,14 @@ +//calculating required data//
+//example 19//
+clc
+//clears the command window//;
+clear
+//clears//
+E=10;//change in input voltage//
+n=8;//no. of bits//
+R=E/((2^n)-1);//resolution//
+disp('resolution:')
+disp(R);//displaying result//
+R1=(1/((2^n)-1))*100;//percentage resolution//
+disp('percentage resolution:')
+disp(R1);//displaying result//
diff --git a/1238/CH8/EX8.2/8_2.sce b/1238/CH8/EX8.2/8_2.sce new file mode 100755 index 000000000..4d3b9f2e5 --- /dev/null +++ b/1238/CH8/EX8.2/8_2.sce @@ -0,0 +1,26 @@ +//calculating the required data//
+//example 2//
+clc
+//clears the command window//
+clear
+//clears//
+n=4;
+WLSB1=1/(2^4-1);//weight assigned to LSB//
+printf('weight assigned to LSB=%f\n',WLSB1)
+WLSB2=2*WLSB1;//weight assigned to 2nd LSB//
+printf('weight assigned to second LSB=%f\n',WLSB2)
+WLSB3=4*WLSB1;//weight assigned to 3rd LSB//
+printf('weight assigned to 3rd LSB=%f\n',WLSB3)
+//high level 1=10V//
+V1=10*WLSB1;//change in output voltage due to change in LSB//
+V2=10*8/15;//change in output voltage due to change in MSB//
+printf('change in output voltage due to change in LSB=%f volt\n',V1)
+printf('change in output voltage due to change in MSB=%f volt\n',V2)
+//results are displayed//
+disp('Vo1=(20/R+40/R+80/R)/(1/R+2/R+4/R+8/R)')
+Vo1=140/15;
+printf('output voltage for input 1110=%f volt\n',Vo1)
+disp('Vo2=(10/R+40/R+80/R)/(1/R+2/R+4/R+8/R)')
+Vo2=130/15;
+printf('output voltage for input 1101=%f volt',Vo2)
+//results are displayed//
diff --git a/1238/CH8/EX8.20/8_20.sce b/1238/CH8/EX8.20/8_20.sce new file mode 100755 index 000000000..d0aec6991 --- /dev/null +++ b/1238/CH8/EX8.20/8_20.sce @@ -0,0 +1,13 @@ +//finding no. of bits//
+//example 20//
+clc
+//clears the command window//;
+clear
+//clears//
+E=10;//change in input voltage//
+R=10^-3;//resolution//
+n=log(E/R+1)/log(2);//no of bits//
+n=n+1;
+n=round(n)
+disp('no of bits:')
+disp(n);//result displayed//
diff --git a/1238/CH8/EX8.21/8_21.sce b/1238/CH8/EX8.21/8_21.sce new file mode 100755 index 000000000..6146fb71c --- /dev/null +++ b/1238/CH8/EX8.21/8_21.sce @@ -0,0 +1,11 @@ +//finding maximum conversion time//
+//example 21//
+clc
+//clears the command window//;
+clear
+//clears//
+c=2^10;//maximum no of counts//
+f=2*10^-6;//counter advance rate of 1 count per second//
+T=c*f;//conversion time//
+disp('maximum conversion time:')
+disp(T);//displaying result//
diff --git a/1238/CH8/EX8.22/8_22.sce b/1238/CH8/EX8.22/8_22.sce new file mode 100755 index 000000000..cfdc62a8a --- /dev/null +++ b/1238/CH8/EX8.22/8_22.sce @@ -0,0 +1,15 @@ +//finding required data//
+//example 22//
+clc
+//clears the command window//;
+clear
+//clears//
+f=500;//frequency//
+F=2*f;//aperture rate//
+t=5*10^-6;//aperture time//
+v=2*%pi*F*t;//error in voltage//
+disp('error in voltage:')
+disp(v);//displaying result//
+V=v*100;//percentage error//
+disp('percentage error:')
+disp(V);//displaying result//
diff --git a/1238/CH8/EX8.23/8_23.sce b/1238/CH8/EX8.23/8_23.sce new file mode 100755 index 000000000..c0c6abf81 --- /dev/null +++ b/1238/CH8/EX8.23/8_23.sce @@ -0,0 +1,11 @@ +//finding aperture time//
+//example 23//
+clc
+//clears the command window//;
+clear
+//clears//
+a=.5;//percentage accuracy//
+f=1000;//aperture rate//
+t=a/(2*%pi)*10^-5;//aperture time//
+disp('aperture time:')
+disp(t);//displaying result//
diff --git a/1238/CH8/EX8.24/8_24.sce b/1238/CH8/EX8.24/8_24.sce new file mode 100755 index 000000000..9b8277e2b --- /dev/null +++ b/1238/CH8/EX8.24/8_24.sce @@ -0,0 +1,10 @@ +//calculating required data//
+//example 24//
+clc
+//clears the command window//;
+clear
+//clears//
+n=10;//no. of bits//
+q=1/(2^n)*100;//quantization error expressed as percentage//
+disp('quantization percentage error:')
+disp(q);//displaying result//
diff --git a/1238/CH8/EX8.25/8_25.sce b/1238/CH8/EX8.25/8_25.sce new file mode 100755 index 000000000..67b465b52 --- /dev/null +++ b/1238/CH8/EX8.25/8_25.sce @@ -0,0 +1,13 @@ +//finding digital output in binary form//
+//example 25//
+clc
+//clears the command window//;
+clear
+//clears//
+V=1.085;//analog input voltage//
+R=20*10^-3;//resolution//
+n=V/R;//no of steps//
+n=round(n);//so that output voltage produced is less than analog input voltage//
+num=dec2bin(n,8);//converting to binary//
+disp('digital output:')
+disp(num);//displaying result in binary form//
diff --git a/1238/CH8/EX8.3/8_3.sce b/1238/CH8/EX8.3/8_3.sce new file mode 100755 index 000000000..56c9be176 --- /dev/null +++ b/1238/CH8/EX8.3/8_3.sce @@ -0,0 +1,16 @@ +//claculating the required data//
+//example 2//
+clc
+//clears the command window//
+clear
+//clears//
+disp('the full scale maximum voltage occurs when all input are at high level 1')
+Vm=10;//full scale maximum output voltage//
+printf('full scale maximum output voltage=%d volt\n',Vm);//result is displayed//
+n=5
+LSB=1/((2^n)-1);//weight of LSB//
+V1=10*LSB;//change in output voltage due to LSB//
+printf('change in output voltage due to change in lsb=%f volt\n',V1)
+disp('analog output voltage for 11001 is given by Vo=(10/R+80/R+160/R)/(1/R+2/R+4/R+8/R+16/R)')
+Vo=250/31;
+printf('analog output voltage for input 11001=%f volt\n',Vo)
diff --git a/1238/CH8/EX8.4/8_4.sce b/1238/CH8/EX8.4/8_4.sce new file mode 100755 index 000000000..6a3735884 --- /dev/null +++ b/1238/CH8/EX8.4/8_4.sce @@ -0,0 +1,16 @@ +//calculating required data//
+//example 4//
+clc
+//clears the command window//
+clear
+//clears//
+a=bin2dec('10010')
+Vo=9*10^-3;//output voltage//
+k=Vo/a;//proportionality factor//
+b=bin2dec('11011')
+Vo1=k*b;//analog output voltage//
+printf('analog output voltage=%f volt\n',Vo1);
+//maximum 5 bit digital input is 11111 i.e. 31 in decimal//
+Vm=k*31;//maximum full scale output voltage//
+printf('maximum full scale output voltage=%f volt',Vm);
+
diff --git a/1238/CH8/EX8.5/8_5.sce b/1238/CH8/EX8.5/8_5.sce new file mode 100755 index 000000000..d102e3bcd --- /dev/null +++ b/1238/CH8/EX8.5/8_5.sce @@ -0,0 +1,20 @@ +//calculating required data//
+//example 5//
+clc
+//clears the command window//;
+clear
+//clears//
+LSB1=10;//change in output voltage due to LSB//
+LSB2=2*LSB1;//change in output voltage due to second LSB//
+LSB3=4*LSB1;//change in output voltage due to third LSB//
+LSB4=8*LSB1;//change in output voltage due to fourth LSB//
+LSB5=16*LSB1;//change in output voltage due to fifth LSB//
+Vmax=LSB1+LSB2+LSB3+LSB4+LSB5;//maximum full scale output which occurs at input 11111//
+//all the voltage units are in mV//
+printf('maximum full scale output in mV at 1111=%d volt\n',Vmax);//displaying the result//
+R=10;//resolution in mV since smallest increment due to change in LSB is 10mV//
+printf('resolution=%d volt\n',R);//diaplaying the result//
+S=10;//step size=resolution//
+R1=S/Vmax*100;//percentage resolution//
+printf('percentage resolution=%f percent',R1);//displaying the result//
+
diff --git a/1238/CH8/EX8.6/8_6.sce b/1238/CH8/EX8.6/8_6.sce new file mode 100755 index 000000000..18c697601 --- /dev/null +++ b/1238/CH8/EX8.6/8_6.sce @@ -0,0 +1,13 @@ +//calculating required data//
+//example 6//
+clc
+//clears the command window//;
+clear
+//clears//
+N=(2^8)-1;//no. of steps//
+M=1000/N;//no. of steps in which motor speed can varied;motor speed varies from 0 to 1000rpm//
+N1=450/M;//no. of steps required to reach 450rpm//
+N2=round(N1);//rounding the no. of steps//
+disp('For 115th step,speed of motor will be approximately 451rpm which gives an accuracy of .22%')
+//displaying the answer//
+
diff --git a/1238/CH8/EX8.7/8_7.sce b/1238/CH8/EX8.7/8_7.sce new file mode 100755 index 000000000..ad5466086 --- /dev/null +++ b/1238/CH8/EX8.7/8_7.sce @@ -0,0 +1,12 @@ +//calculating values of resistors//
+//example 7//
+clc
+//clears the command window//;
+clear
+//clears//
+R1=10*10^3;//resistor in ohm for msb//
+R=16*R1;//resistor for LSB//
+R2=R/2;//resistor for 2nd LSB//
+printf('resistor for lsb=%d ohm\n',R)
+printf('resistor for 2nd lsb=%d ohm',R2)
+
diff --git a/1238/CH8/EX8.8/8_8.sce b/1238/CH8/EX8.8/8_8.sce new file mode 100755 index 000000000..e199b1c26 --- /dev/null +++ b/1238/CH8/EX8.8/8_8.sce @@ -0,0 +1,9 @@ +//calculating value of resistor//
+//example 8//
+clc
+//clears the command window//;
+clear
+//clears//
+R=640*(10^3);//resistor for LSB//
+R1=R/32;//resistor for MSB;since 6 bit,hence LSB is divided by 32//
+printf('resistor for msb=%d ohm',R1);//displaying result//
diff --git a/1238/CH8/EX8.9/8_9.sce b/1238/CH8/EX8.9/8_9.sce new file mode 100755 index 000000000..2f251ab5d --- /dev/null +++ b/1238/CH8/EX8.9/8_9.sce @@ -0,0 +1,12 @@ +//calculating required data//
+//example 9//
+clc
+//clears the command window//;
+clear
+//clears//
+N=2^10-1;//no. of steps//
+Vmax=10*10^-3*N;//maximum full scale output//
+R=(10*10^-3)/Vmax*100;//percentage resolution//
+printf('maximum full scale output=%f ampere\n',Vmax)
+printf('percentage resolution=%f percent',R)
+
|