How to write a C Program String Count in C Programming Language ?
Solution For C Program :
//C Program String Count.
#include <stdio.h>
#include <ctype.h>
int main(){
char s[1005];
gets(s);
int count[26] = {0};
int i;
for( i = 0 ; s[i] != '\0' ; i++ ){
s[i] = tolower(s[i]);
/*
if( s[i] == 'a' ){
count[0]++;
}
else if( s[i] == 'b' ){
count[1]++;
}
else if( s[i] == 'c' ){
count[2]++;
}
else if( s[i] == 'd' ){
count[3]++;
}
else if( s[i] == 'e' ){
count[4]++;
}
...
*/
if( islower(s[i]) ){
int index = s[i] - 'a';
count[index]++;
}
}
for( i = 0 ; i < 26 ; i++ ){
printf("%c: %d\n", i+'a', count[i]);
}
return 0;
}
Program related to C Programming Language :
- C Program Array Index Example
- C Program String - Alphabet Count Example
- C Program Character toupper() Example
- C Program Array Example: Average
- C Program Array Example: Reverse
- C Program if - while - for Example
- C Program Switch - Case Example
- C Program 0.1 + 0.2 != 0.3 Solved
- C Program if - else if - else Example
- C Program typedef Example
- C Program scanf & gets Example
- C Program Friend & Operator: Point2D Example
- C Program Friend & Operator: Vector Example
- C Program Recursion Example
- C Program File Input & Output Example
- C Program Structure Example-2
- C Program Structure Example
- C Program Pointer Example
- C Program Function Example
- C Program String Example
- C Program String Count Example
- C Program String Example
- C Program Character Example
- C Program Sort Example
- C Program sizeof & memcpy Example
- C Program Array Example
- C Program to Array
- C Program print fill zero & mod/div
- C Program Double, Float Equal
- C Program nested for
- C Program for
- C Program if
- C Program System
- C Program Operation
- C Program to printf & scanf
- Example C Program Cuda Malloc
- C Program Side Length
Learn More :
Count
- C Program String - Alphabet Count Example
- Write the procedure , which is one of a sum , a product and a geometric average in the panel for the NxM elements are located on opposite diagonal and main diagonal . Remind ! Counting only odd elements !
- C Program Array NxM Elements Geometric/Arithmetic
- C Program to Count Number of Lines in Input until Interrupted by CTRL + Z
- Returns: array of decoded values. [0] - count of values
- Max count of chars, Max count of nums and Max count of signs
- C Program to Count Vowels, Consonants and Spaces in a string
- C Program to count number of sentences words and letters in a paragraph
- Un-sortiertes Array and Sortiertes Array
- C Program to Count Change Program
- LED ON OFF For One Sec/Count and Display on the Attached Serial Monitor
- Menu driven program in C which performs the following operations on strings
- C program to accept n number from user,store these numbers into an array & count the no of occurrences of each number
String
- Write a c program to check given string is palindrome number or not.
- C Program to Convert Text String to Binary
- C Program String - Alphabet Count Example
- C Program String Example
- C Program String Example
- C Program to Print a String Without Use Semicolon.
- C Program To Find Length Of A String Including Blank Spaces, Tabs, And Other Special Characters
- C Program To Find Length Of String And Concatenate Two Strings
- C Program To Find The Length, Reverse Of A String And To Check It Is Palindrome or Not
- C Program To Print String In Formatted Output Form
- C Program To Reverse The String Using Pointer
- C Program Concatenating Two Strings Into A Third System
- C Program Date from string DDDD-DD-DD
- BUILDS A STRING FROM THE LSB BITS OF EACH PIXEL
- C Program Finds Sub-String Search in String
- C Program to concatenate two strings without using string functions
- C Program to Count Vowels, Consonants and Spaces in a string
- C Program to convert a string to upper case
- C Program Performs a search and replace for a specified target and replacement string
- C Program Anagrams
- C Program to find string length without library function
- C Program to Check Given String is Palindrome or Not
- C Program to Converts a Number to a String.
- Design a C function that shortens a string to 8 characters