30 Easy C++ Programming Questions on the topic String


Q 1. Write a Program to Print a string?

Expected Output:

Hello, World!

Q 2. Write a Program to take Input and print a string?

Expected Output:

(Input: Welcome)

You entered: Welcome

Q 3. Find the length of a string

Expected Output:

Length of string = 11

Q 4. Write a Program to Concatenate two strings

Expected Output:

Hello, World!

Q 5. Write a Program to Compare two strings

Expected Output:

Strings are not equal

Q 6. Write a Program to Convert a string to uppercase

Expected Output:

TECHNOVLOGS

Q 7. Write a Program to Convert a string to lowercase

Expected Output:

technovlogs

Q 8. Find a character at a specific index

Expected Output:

Character at index 4: r

Q 9. Write a Program to Count vowels in a string

Expected Output:

Number of vowels = 3

Q 10. Write a Program to Check if a string is a palindrome

Expected Output:

Palindrome

Q 11. Write a Program to Reverse a string

Expected Output:

sgolvonhcet

Q 12. Find the frequency of a character in a string

Input - programming

Expected Output:

Frequency of 'g' = 2

Q 13. Replace a character in a string

Expected Output:

hexxo worxd

Q 14. Write a Program to Erase part of a string

Input - Hello, World!

Expected Output:

Hello

Q 15. Find a substring in a string

Expected Output:

Substring found at index 7

Q 16. Convert an integer to a string

Expected Output:

String: 1234

Q 17. Convert a string to an integer

Expected Output:

Integer: 5678

Q 18. Split a string by spaces (simple version)

Input - This is a test

Expected Output:

This

is

a

test

Q 19. Find the first occurrence of a character

Input - hello world

Expected Output:

First occurrence of 'o' is at index 4

Q 20. Find the last occurrence of a character

Input - hello world

Expected Output:

Last occurrence of 'o' is at index 7

Q 21. Check if a string contains only digits

Input - 12345

Expected Output:

String contains only digits

Q 22. Convert a character to its ASCII value

Expected Output:

ASCII value of 'A' = 65

Q 23. Count uppercase letters in a string

Input - Hello World!

Expected Output:

Number of uppercase letters = 2

Q 24. Count lowercase letters in a string

Input - Hello World!

Expected Output:

Number of lowercase letters = 8

Q 25. Insert a substring into a string

Expected Output:

Hello Beautiful World!

Q 26. Remove all spaces from a string

Input - Hello World!

Expected Output:

HelloWorld!

Q 27. Count the words in a string

Input - This is a test string

Expected Output:

Number of words = 5

Q 28. Check if two strings are anagrams

Input - 1st string - listen and 2nd string - silent

Expected Output:

Strings are anagrams

Q 29. Count consonants in a string

Input - hello world

Expected Output:

Number of consonants = 7

Q 30. Remove duplicate characters from a string

Input - programming

Expected Output:

String after removing duplicates: progamin

Social Share

Bikki Singh

Hi, I am the instructor of TechnoVlogs. I have a strong love for programming and enjoy teaching through practical examples. I made this site to help people improve their coding skills by solving real-world problems. With years of experience, my goal is to make learning programming easy and fun for everyone. Let's learn and grow together!

Programming Languages