Computer Science, asked by bhaveshbhatia30aug, 1 month ago

Design a menu driven program for following operation:

a) Create a string using linked stack by pushing each character at one time .

b) Replace the special symbol substring with only ‘#’.

c) Display current status of string

Answers

Answered by deepalmsableyahoocom
0

Answer:

a) Create a string using linked stack by pushing each character at one time .

Stack<Character> myStack = new Stack<Character>(); char letter = 'a'; myStack. push((Character) letter); Create a stack that contains Character objects, and cast your char s to Character before you insert them. Just like int s and Integer s, you need to wrap a primitive before you can insert it in to a data structure.

b) Replace the special symbol substring with only ‘#’.

Algorithm to Replace a substring in a string

1) Input the full string (s1).

2) Input the substring from the full string (s2).

3) Input the string to be replaced with the substring (s3).

4) Find the substring from the full string and replace the new substring with the old substring (Find s2 from s1 and replace s1 by s3).

c) Display current status of string.

To compare more than 2 strings in c we use strcmp() function. We also need to include string.h header file in the program.

Similar questions