0% found this document useful (0 votes)
21 views1 page

C String Practice Workbook

The document is a C Language String Practice Workbook containing various problems and solutions related to string manipulation. It includes tasks such as counting character frequency, converting case, finding non-repeating characters, and checking for anagrams. Each problem is accompanied by code snippets demonstrating the solution approach.

Uploaded by

myindiabharat600
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)
21 views1 page

C String Practice Workbook

The document is a C Language String Practice Workbook containing various problems and solutions related to string manipulation. It includes tasks such as counting character frequency, converting case, finding non-repeating characters, and checking for anagrams. Each problem is accompanied by code snippets demonstrating the solution approach.

Uploaded by

myindiabharat600
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/ 1

C Language String Practice Workbook

Problems and Solutions

1. Count Frequency of Each Character

char str[100]; int freq[256] = {0}; ...

2. Convert Lowercase to Uppercase

for(int i = 0; str[i] != '\0'; i++) if(str[i] >= 'a' && str[i] <= 'z') str[i] -= 32;

3. First Non-Repeating Character

for(int i = 0; str[i]; i++) freq[(unsigned char)str[i]]++; ...

4. Remove All Vowels

if(!isVowel(str[i])) result[j++] = str[i];

5. Check for Anagram

for(i = 0; i < len1; i++) count[str1[i]]++, count[str2[i]]--;

6. Remove All Whitespaces

if(str[i] != ' ' && str[i] != '\t') result[j++] = str[i];

7. Toggle Case

if(str[i] >= 'A' && str[i] <= 'Z') str[i] += 32; else if(str[i] >= 'a' && str[i] <= 'z') str[i] -= 32;

8. Most Frequent Character

freq[(unsigned char)str[i]]++; if(freq[...] > max) ...

9. Check if String Contains Only Digits

if(!isdigit(str[i])) isDigit = 0;

10. Replace Spaces with Hyphens

if(str[i] == ' ') str[i] = '-';

You might also like