summaryrefslogtreecommitdiff
path: root/659/CH8/EX8.8
diff options
context:
space:
mode:
authorpriyanka2015-06-24 15:03:17 +0530
committerpriyanka2015-06-24 15:03:17 +0530
commitb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch)
treeab291cffc65280e58ac82470ba63fbcca7805165 /659/CH8/EX8.8
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 '659/CH8/EX8.8')
-rwxr-xr-x659/CH8/EX8.8/exm8_8.sce32
-rwxr-xr-x659/CH8/EX8.8/exm8_8_output.PNGbin0 -> 20116 bytes
2 files changed, 32 insertions, 0 deletions
diff --git a/659/CH8/EX8.8/exm8_8.sce b/659/CH8/EX8.8/exm8_8.sce
new file mode 100755
index 000000000..41a558522
--- /dev/null
+++ b/659/CH8/EX8.8/exm8_8.sce
@@ -0,0 +1,32 @@
+// Example 8.8
+//s1,s2 and s3 are three string variables. Write a program to read two string-
+//constants in to s1 and s2 and compare whether they are equal or not,join-
+//them together. Then copy contents of s1 to variable s3. At the end program-
+// should print all three variables and their lengths
+
+
+//Read data
+printf("Enter two string constants\n");
+[s1 s2]=scanf("%s %s");
+
+//Comparing two strings
+x=strcmp(s1,s2);
+if x~=0 then
+ printf("String are not equal\n");
+ //Concatinate two strings s1 and s2
+ s1=strcat([s1,s2]);
+else
+ printf("String are equal\n");
+end
+
+l1=length(s1);
+//Coping s1 to s3
+s3=strncpy(s1,l1);
+//finding length of strings
+l2=length(s2);
+l3=length(s3);
+//Output
+printf("s1 = %s\t length = %d characters\n",s1,l1);
+printf("s2= %s\t length = %d characters\n",s2,l2);
+printf("s3= %s\t length = %d characters\n",s3,l3);
+
diff --git a/659/CH8/EX8.8/exm8_8_output.PNG b/659/CH8/EX8.8/exm8_8_output.PNG
new file mode 100755
index 000000000..d86ff3867
--- /dev/null
+++ b/659/CH8/EX8.8/exm8_8_output.PNG
Binary files differ