## Compare 2 strings,join 2 strings,length of a given string, Programming Languages

Assignment Help:

W.A.S.S to perform following string operations using menu:

i.    Compare two strings.

ii.    Join two strings.

iii.    Find the length of a given string.

iv.    Occurrence of character and words.

v.    Reverse the string.

Program

#W.A.S.S. to perform string operation: compare, concate, find, occurance, reverse

echo "1) Compare two strings."

echo "2) Join two strings."

echo "3) Find the length of a given string."

echo "4) Occurence of character."

echo "5) Occurrence of words."

echo "6) Reverse the string."

echo -e "Enter the choice.: \c"

case \$c in

1)       echo -e "Enter string1:\c"

echo -e "Enter stingr2: \c"

if test \$str1 = \$str2

then

echo "Entered strings are same."

else

echo "Entered string are not same."

fi

;;

2)       echo -e "Enter string 1: \c"

echo -e "Enter string 2: \c"

str3=`echo "\$str1\$str2"`

echo -e "Joint string is: \c"

echo "\$str3"

;;

3)        echo -e "Enter the string: \c"

echo -e "Length of the string is: \c"

echo "\$str" | wc -c

;;

4)        echo -e "Enter the string: \c"

echo -e "Enter the  character to count the occurance: \c"

len=`echo "\$str" | wc -c`

len=`expr \$len - 1`

occ=0

while test \$len -gt 0

do

tc=`echo "\$str" | cut -c\$len`

if test \$tc = \$ch

then

occ=`expr \$occ + 1`

fi

len=`expr \$len - 1`

done

echo "No.of occurence : \$occ"

;;

5)       echo -e "Enter the string: \c"

echo -e  "Enter the  word to count the occurance: \c"

occ=0

for w in `echo "\$str"`

do

if test \$cw = \$w

then

occ=`expr \$occ + 1`

fi

done

echo "No.of occurence : \$occ"

;;

6)        echo -e "Enter the string: \c"

len=`echo \$str | wc -c`

len=`expr \$len - 1`

result=""

while test \$len -gt 0

do

temp=`echo \$str | cut -c \$len`

len=`expr \$len - 1`

result=`echo \$result\$temp`

done

echo "Reverse string is: \$result"

;;

esac

Output

1) Compare two strings.

2) Join two strings.

3) Find the length of a given string.

4) Occurence of character.

5) Occurrence of words.

6) Reverse the string.

Enter the choice.: 1

Enter string1:mca

Enter stingr2: mca

Entered strings are same.

Enter the choice.: 2

Enter string 1: SVIT

Enter string 2: MCA

Joint string is: SVITMCA

Enter the choice.: 3

Enter the string: SVIT

Length of the string is:       4

Enter the choice.: 4

Enter the string: SEMESTER

Enter the  character to count the occurance: E

No.of occurence : 3

Enter the choice.: 5

Enter the string: welcome to svit svit svit

Enter the  word to count the occurance: svit

No.of occurence : 3

Enter the choice.: 6

Enter the string: SVIT

Reverse string is: TIVS

#### Abstraction hierarchy of mechanisms, Abstraction hierarchy of mechanisms ...

Abstraction hierarchy of mechanisms Given  the light-sensitive the motor and resistor,  we could  find  several  ways  of interconnecting them, using bits of ceramic and metal

#### Programming, You must programme an analogue clock and digital stopwatch usi...

You must programme an analogue clock and digital stopwatch using the Processing programming language

#### Program for create a menu, The creation of the menu will involve writing pr...

The creation of the menu will involve writing procedural code, using decision logic, writing a loop, and using the case statement.  Although it is not required for grading, it is r

#### Created xml document using the css stylesheet, After studying the concept, ...

After studying the concept, terminology, and implementation of CSS stylesheets, create a stylesheet to accompany your solutions to Question 1. A rich collection of styles should be

#### Example of undetermined coefficients, Example :  Solve the following differ...

Example :  Solve the following differential equation. y (3)   -  12 y''+48 y' + 64 y = 12 - 32 e -8t + 2 e 4t Solution :    We first require the complementary solution

#### COS-101: INTRODUCTION TO COMPUTERS, COS-101: INTRODUCTION TO COMPUTERS PRO...

COS-101: INTRODUCTION TO COMPUTERS PROJECT DESCRIPTION The Computer Fundamentals Project provides you with a chance to apply what you have learned about computer fundamentals to

#### Java, wat is- m=5; n=3; x=m++-n+++m;

wat is- m=5; n=3; x=m++-n+++m;

#### Visual basic 2010, I have to create a calorie counter and I am totally lost...

I have to create a calorie counter and I am totally lost

#### Characteristics of object-oriented programming, Characteristics of object-o...

Characteristics of object-oriented programming: •   Emphasis is on data rather than procedure. •   Programs are divided into what are known as objects. •

#### Dot net technology, write a procedure to add toolbar in VB application addi...

write a procedure to add toolbar in VB application adding icons to toolbar buttons & with the approprite example display the use of each button

### Write Your Message!

#### Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!