C Program to Count Alphabets, Digits and Special Characters in a String

In this tutorial you will learn about the C Program to Count Alphabets, Digits and Special Characters in a String and its application with practical example.

C Program to Count Alphabets, Digits, and Special Characters in a String

In this tutorial, we will learn to create a C program that will Count Alphabets, Digits, and Special Characters in a String in C programming

Table Of Contents

Prerequisites

Before starting with this tutorial, we assume that you are the best aware of the following C programming topics:

  • Operators in C Programming.
  • Basic Input and Output function in C Programming.
  • Basic C programming.
  • For loop in c programming.

What is a string?

The String is a collection of characters and words. The word is a collection of alphabets. For string, only one variable is declared which can store multiple values. The String can consist of all the typeable data, it means Digits, Alphabets, Symbols, etc. A character is any single entity that is used in combination to form a word.

Algorithm:-

Count Alphabets, Digits, and Special Characters in a String

First, will take the line of string from the user. Then will count Alphabets, Digits, and Special Characters from that strings. At last, we will print the result numbers.

With the help of this program, we can Count Alphabets, Digits, and Special Characters in a String.

Program Code:-

Output:-

In the above program, we have first initialized the required variable.

  • str[str_size] = it will hold the string value.
  • apls= it will hold the integer value for vowels.
  • di = it will hold the integer value for digits.
  • splchar = it will hold the integer value for special characters.
  • i = it will hold the integer value.

Input strings from the user.

Filtering the digits and the special character from the string.

Printing output numbers of the alphabets, the special characters, and the digits.

In this tutorial we have learn about the C Program to Count Alphabets, Digits and Special Characters in a String and its application with practical example. I hope you will like this tutorial.