0% found this document useful (0 votes)
27 views

(Strings) Computer Programming

The document contains 5 programming problems involving string manipulation in various ways: 1) Check if a string is a palindrome 2) Insert a substring into a main string at a specified location 3) Check if two strings are equal without using built-in comparison functions 4) Remove a specified character from a string 5) Replace all instances of a substring in a string Each problem is accompanied by sample input, output, and code to solve the problem.

Uploaded by

Usama Nawaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

(Strings) Computer Programming

The document contains 5 programming problems involving string manipulation in various ways: 1) Check if a string is a palindrome 2) Insert a substring into a main string at a specified location 3) Check if two strings are equal without using built-in comparison functions 4) Remove a specified character from a string 5) Replace all instances of a substring in a string Each problem is accompanied by sample input, output, and code to solve the problem.

Uploaded by

Usama Nawaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

(Strings)

Computer Programming

Program#1:
Write a program that takes a string as input from user then prints whether it is palindrome or not.
(Palindrome is a type of word play in which a word, phrase, or sentence reads the same
backward or forward)
Output
Enter a string
no evil shahs live on
The given string is a Palindrome string

Program#2:
Write a program that inputs a string, a sub-string and location (where user wants to add
substring) and then inserts the substring to the location provided by the user.
Output
Enter a string:
Pleases this application and give me gratuity
Enter Substring: read
Location : 7
After inserting substring final output is
Pleases read this application and give me gratuity

Program#3:
Write a program that takes two strings as input from user then prints whether both strings are
equal or not without using built-in function of strcmp().
Output
Enter first string:
He that lives upon hope will die fasting
Enter second string:
He that lives upon hope will die fasting
The given strings are equal

Program#4:
Write a program that takes a string and a character from user as input then remove that character
from the string and print the final string.
Output

Enter the string:


He that lives upon hope will die fasting
Enter the character you want to remove: i
Final string after removing i is:
He that lves upon hope wll de fastng

Program#5:
Write a program that takes a string as input then replaces all words of is by was.
Output
Enter the string:
This blue pen is for the kid, which is wearing blue shirt and is looking healthy.
Final string after replacement is:
This blue pen was for the kid, which was wearing blue shirt and was looking healthy.

_________________

You might also like