String programming exercises and solutions in C

Strings are basically array of characters that represent some textual data in a program. Here are basic string programs with detailed explanation that will help to enhance your string programming skills. These exercises can be practiced by anyone a beginner or an intermediate programmers.

  1. Write a C program to find length of a string.
  2. Write a C program to copy one string to another string.
  3. Write a C program to concatenate two strings.
  4. Write a C program to compare two strings.

  5. Write a C program to convert lowercase string to uppercase.
  6. Write a C program to convert uppercase string to lowercase.
  7. Write a C program to toggle case of each character of a string.

  8. Write a C program to find total number of alphabets, digits or special character in a string.
  9. Write a C program to count total number of vowels and consonants in a string.
  10. Write a C program to count total number of words in a string.
  11. Write a C program to find reverse of a string.
  12. Write a C program to check whether a string is palindrome or not.
  13. Write a C program to reverse order of words in a given string.

  14. Write a C program to find first occurrence of a character in a given string.
  15. Write a C program to find last occurrence of a character in a given string.
  16. Write a C program to search all occurrences of a character in given string.
  17. Write a C program to count occurrences of a character in given string.
  18. Write a C program to find highest frequency character in a string.
  19. Write a C program to find lowest frequency character in a string.
  20. Write a C program to count frequency of each character in a string.
  21. Write a C program to remove first occurrence of a character from string.
  22. Write a C program to remove last occurrence of a character from string.
  23. Write a C program to remove all occurrences of a character from string.
  24. Write a C program to remove all repeated characters from a given string.
  25. Write a C program to replace first occurrence of a character with another in a string.
  26. Write a C program to replace last occurrence of a character with another in a string.
  27. Write a C program to replace all occurrences of a character with another in a string.

  28. Write a C program to find first occurrence of a word in a given string.
  29. Write a C program to find last occurrence of a word in a given string.
  30. Write a C program to search all occurrences of a word in given string.
  31. Write a C program to count occurrences of a word in a given string.
  32. Write a C program to remove first occurrence of a word from string.
  33. Write a C program to remove last occurrence of a word in given string.
  34. Write a C program to remove all occurrence of a word in given string.

  35. Write a C program to trim leading white space characters in a string.
  36. Write a C program to trim trailing white space characters in a string.
  37. Write a C program to trim both leading and trailing white space characters in a string.
  38. Write a C program to remove all extra blank spaces from a given string.



Any doubt or suggestion write here. I will try my best to help. Before posting your code you must escape it to view. To format your source code and use format highlighting, post your source code inside
< code >< pre > -- Your source code -- < /pre >< /code > (Remove spaces from pre and code tags).

No comments:

Post a Comment