AN SET1 Q1


Submit solution

Points: 10 (partial)
Time limit: 8.0s
Memory limit: 64M

Authors:
Problem type
Allowed languages
C

Problem Statement

As a coding enthusiast, you are developing a program in strings for 2 purposes.

1.For altering all occurrences of a specific alphabet in a message with another alphabet.

2.Find the frequency of a particular character in the string.

Get the input string, followed by the option number from the user.

For option 1, get the character to be replaced followed by the new character to be inserted as inputs from the user. Then display the altered string by including the new character.

For option 2, get the character as input from the user. Then output the total number of occurrences of the entered character in the string.

The following test cases (Sample Input & output) are examples. Each such test case should be handled by your program.

Note: Your program should handle strings with spaces also.

Input Format

The first line contains the input string. The second line contains the option number. For option 1, get the character to be replaced and new character in third and fourth lines respectively. For option 2, get the character in the third line whose frequency to be found.

Output Format

For option 1, The altered string will be displayed in a line. For option 2, The total number of occurrences of character in the string will be displayed in a line

Sample Input1

Cat

1

C

M

Sample Output1

Mat

Sample Input2

Cat

2

C

Sample Output2

1

Explanation of Input1-Output1 (Only for understanding purpose):

First Line: Cat is the input string.

Second line: Option number is 1.

Third line: C, the character to be replaced in the input string.

Fourth Line: M, the character to be inserted in all occurrences of C.

The output is the altered string and is displayed in a new line.


Comments

There are no comments at the moment.