summaryrefslogtreecommitdiff
path: root/48/CH2/EX2.5/eg_2_5.sce
diff options
context:
space:
mode:
authorpriyanka2015-06-24 15:03:17 +0530
committerpriyanka2015-06-24 15:03:17 +0530
commitb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch)
treeab291cffc65280e58ac82470ba63fbcca7805165 /48/CH2/EX2.5/eg_2_5.sce
downloadScilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.gz
Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.bz2
Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.zip
initial commit / add all books
Diffstat (limited to '48/CH2/EX2.5/eg_2_5.sce')
-rwxr-xr-x48/CH2/EX2.5/eg_2_5.sce61
1 files changed, 61 insertions, 0 deletions
diff --git a/48/CH2/EX2.5/eg_2_5.sce b/48/CH2/EX2.5/eg_2_5.sce
new file mode 100755
index 000000000..a43c42d09
--- /dev/null
+++ b/48/CH2/EX2.5/eg_2_5.sce
@@ -0,0 +1,61 @@
+clear;
+clc;
+//N=input("enter the no of elements in the set :");
+//for i=1:1:N
+// s(1,i)=input("enter the elements in the set :");
+//end;
+//n=input("enter the number of pairs in the relation :");
+//for j=1:1:n
+// for k=1:1:2
+// r(j,k)=input("enter the elements in the relation :");
+// end
+//end
+N=2;
+s=['a' 'b']; //elements in the set
+n=3;
+r=['a' 'a';'b' 'b';'a' 'b']; //realtion between the elements in the above set.
+ref=zeros(1,N);
+for a=1:1:N
+ for b=1:1:n
+ if(r(b,1)==s(1,a)&r(b,2)==s(1,a))
+ ref(1,a)=1;
+ end
+ end
+end
+for i=1:1:N //checking whether above relation is reflexive or not
+ if(ref(1,i)==1)
+ disp("the above relation is reflexive with elements ");
+ disp(s(1,i));
+ disp(" ");
+ end
+end
+sym=zeros(1,(N*N-1)/2);
+s(1,N+1)=s(1,1);
+for a=1:1:N //checking whether above relation is symmetric or not
+ for b=1:1:n
+ if(r(b,1)==s(1,a)&r(b,2)==s(1,a+1))
+ for d=1:1:n
+ if(r(d,1)==s(1,a+1)&r(d,2)==s(1,a))
+ sym(1,a)=1;
+ disp("the above relation is symmetric for these pairs :");
+ disp(")",s(1,a+1),s(1,a),"(");
+ end
+ end
+ end
+ end
+end
+for a=1:1:n //checking whether it is transtive or not.
+ u=r(a,1);
+ v=r(a,2);
+ for b=a:1:n
+ if(r(b,1)==v)
+ w=r(b,2);
+ for c=b:1:n
+ if(r(c,1)==w&r(c,2)==u)
+ disp("satisfies transtitve property");
+ abort;
+ end
+ end
+ end
+ end
+end \ No newline at end of file