C string examples

C Programs - String

Practice C programs based on strings, character arrays, null termination, frequency, replacement, trimming, and word operations.

Topic library

32

practice programs

Topic overview

String is one of the most frequently used data structures in programming.

In C, a string is a sequence of characters stored in a character array and terminated with the null character \0.

These programs help you practice input, traversal, frequency counting, character replacement, word search, trimming, and removing duplicates.

Practice list

String programs in C

32 programs
  1. 1C Program to take string as an input
  2. 2C Program to find length of a string
  3. 3C Program to copy one string to another string
  4. 4C Program to concatenate two strings
  5. 5C Program to convert lowercase string to uppercase
  6. 6C Program to convert uppercase string to lowercase
  7. 7C Program to toggle case of a string
  8. 8C Program to count alphabets, digits and special characters in a string
  9. 9C Program to count number of vowels and consonants in a string
  10. 10C program to count number of words in a string
  11. 11C program to find reverse of a string
  12. 12C Program to check if a string is a palindrome
  13. 13C program to find first occurrence of a character in a string
  14. 14C program to find last occurrence of a character in a string
  15. 15C program to search all occurrences of a character in a string
  16. 16C program to find highest frequency character in a string
  17. 17C program to find lowest frequency character in a string
  18. 18C program to count frequency of each character in a string
  19. 19C program to remove first occurrence of a character from string
  20. 20C program to remove last occurrence of a character from string
  21. 21C program to remove all occurrences of a character from string
  22. 22C program to remove all repeated characters from a given string
  23. 23C Program to replace first occurrence of a character in a string
  24. 24C Program to replace last occurrence of a character in a string
  25. 25C program to replace all occurrences of a character in a string
  26. 26C program to find first occurrence of a word in a string
  27. 27C program to search all occurrences of a word in a string
  28. 28C program to remove first occurrence of a word from string
  29. 29C program to remove last occurrence of a word from string
  30. 30C program to remove all occurrence of a word from string
  31. 31C program to trim leading and trailing white spaces from string
  32. 32C program to remove all extra blank spaces from string