From b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b Mon Sep 17 00:00:00 2001 From: priyanka Date: Wed, 24 Jun 2015 15:03:17 +0530 Subject: initial commit / add all books --- 659/CH8/EX8.8/exm8_8.sce | 32 ++++++++++++++++++++++++++++++++ 659/CH8/EX8.8/exm8_8_output.PNG | Bin 0 -> 20116 bytes 2 files changed, 32 insertions(+) create mode 100755 659/CH8/EX8.8/exm8_8.sce create mode 100755 659/CH8/EX8.8/exm8_8_output.PNG (limited to '659/CH8/EX8.8') 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 Binary files /dev/null and b/659/CH8/EX8.8/exm8_8_output.PNG differ -- cgit