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 /37/CH1/EX1.5 | |
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 '37/CH1/EX1.5')
-rwxr-xr-x | 37/CH1/EX1.5/Solved5.sci | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/37/CH1/EX1.5/Solved5.sci b/37/CH1/EX1.5/Solved5.sci new file mode 100755 index 000000000..259e2b86c --- /dev/null +++ b/37/CH1/EX1.5/Solved5.sci @@ -0,0 +1,24 @@ +//Solved Example 7:
+//Reducing The Given Rational Number
+funcprot(0)
+function[y]=reduce(nm,dn)
+rational1=struct('numerator',nm,'denominator',dn)
+y=0
+if(rational1.numerator>rational1.denominator)
+ a=rational1.numerator;
+ b=rational1.denominator;
+else
+ a=rational1.denominator;
+ b=rational1.numerator;
+end
+while(b~=0)
+ rem=modulo(a,b);
+ a=b;
+ b=rem;
+end
+y=struct('numerator',nm/a,'denominator',dn/a);
+disp(y);
+endfunction
+nm=22;
+dn=44;
+y=reduce(nm,dn)
\ No newline at end of file |