Category Archives: C Programs

C Programs

C Program to Check the Character is Lowercase or Uppercase Alphabet

C Program to Check Character is Lowercase or Uppercase Alphabet

In this tutorial, we will learn to create a C program that will Check the Character in Lowercase or Uppercase Alphabet in C programming.

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.
  • Conditional Statements in C programming.

What is a character?

The character is a single alphabetical entity in the English language and in any word. These letters can be both capital & small or uppercase & lowercase.

For Example:-

In the “Hello” word the there are five characters they are as follows

  1. “H”
  2. “e”
  3. “l”
  4. “l”
  5. “o”

Here,

“H” is an uppercase letter.

“e” is a lowercase letter.

“l” is a lowercase letter.

“l” is a lowercase letter.

“o” is a lowercase letter.

Algorithm:-

Program to Check the Character is Lowercase or Uppercase Alphabet

First, will take the character in input from the user. Then will pass that character in the conditional statements to find whether it is an upper case character or in lowercase.

With the help of this program, we can Check the Character in Lowercase or Uppercase Alphabet.

Program Code:-

Output:-

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

  • chr = it will hold the character value for the input.

Input character from the user.

Finding the character is in upper case or lower case.

Printing output for the program.

C Program to Check Whether Character is Uppercase or Not

C Program to Check Whether Character is Uppercase or Not

In this tutorial, we will learn to create a C program that will Check Whether Character is Uppercase or Not in C programming.

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.
  • Conditional Statements in C programming.

What is a character?

The character is a single alphabetical entity in the English language and in any word. These letters can be both capital & small or uppercase & lowercase.

For Example:-

In the “Hello” word the there are five characters they are as follows

  1. “H”
  2. “e”
  3. “l”
  4. “l”
  5. “o”

Hence, “H” is a capital letter/ uppercase letter.

Algorithm:-

Program to Check Whether Character is Uppercase or Not

First, will take the character in input from the user. Then will pass that character in the conditional statements to find whether it is an upper case character or not.

With the help of this program, we can Check Whether the Character is Uppercase or Not.

Program Code:-

 

Output:-

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

  • chr = it will hold the character value for the input.

Input character from the user.

Finding the character is in upper case or not.

Printing output for the program.

C Program to Find First Occurrence of a Word in a String

C Program to Find First Occurrence of a Word in a String

In this tutorial, we will learn to create a C program that will Find the First Occurrence of a Word in a String in C programming

Prerequisites

Before starting with this tutorial we assume that you are 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.
  • Conditional Statements in C programming.

What is a string?

As we all know 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.

Algorithm:-

Find the First Occurrence of a Word in a String

In this program first, we will take input string from the user. Then we will take the word to be searched from the user. Then will find the first occurrence of that word in that string. Printing the position of that word.

Let us take the example program from the below code to search for the first occurrence of that word.

Program:-

 

Output:-

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

  • strg[100] = it will hold the string value.
  • word[100] = it will hold the string value.
  • j = it will hold the integer value.
  • i = it will hold the integer value.
  • flag = it will hold the integer value

Input string from the user for the program and Take the input Word from the user to search.

Searching the word in the string.

Printing output position of the word.

C Program to Find Last Occurrence of a Character in a String

C Program to Find Last Occurrence of a Character in a String

In this tutorial, we will learn to create a C program that will Find the Last Occurrence of a Character in a String in C programming

Prerequisites

Before starting with this tutorial we assume that you are 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.
  • Conditional Statements in C programming.

What is a string?

As we all know the String is a collection of characters. In strings, 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. In this program, we will use strings.

Algorithm:-

Find Last Occurrence of a Character in a String

In this program first, we will take input string from the user. Then we will take the character to be searched from the user. Then will Find the last occurrence of that character in that string. Printing the position of that Character.

With the help of this program, we can Find the Last Occurrence of a Character in a String.

Program:-

 

Output:-

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

 

  • strg[100] = it will hold the string value.
  • ch = it will hold the character value.
  • indx = it will hold the integer value.
  • i = it will hold the integer value.

Input string from the user for the program and Take the input character from the user to search.

Searching the Character in the string.

Printing output position of the string.

C Program to Find First Occurrence of a Character in a String

C Program to Find First Occurrence of a Character in a String

In this tutorial, we will learn to create a C program that will Find the First Occurrence of a Character in a String in C programming

Prerequisites

Before starting with this tutorial we assume that you are 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.
  • Conditional Statements 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:-

Find the First Occurrence of a Character in a String

In this program first, we will take input string from the user. Then we will take the Character to be searched from the user. Then will find the first occurrence of that Character in that string. Printing the position of that character.

Let us take the example program from the below code to search for the first occurrence of that Character.

Program:-

 

Output:-

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

  • strg[100] = it will hold the string value.
  • ch = it will hold the character value.
  • j = it will hold the integer value.
  • i = it will hold the integer value.
  • flag = it will hold the integer value

Input string from the user for the program and Take the input character from the user to search.

Searching the character in the string.

Printing output position of the character.

C Program to Count Total Number of Words in a String

C Program to Find First Occurrence of a Word in a String

In this tutorial, we will learn to create a C program that will Count Total Number of Words in a String in C programming

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.
  • Conditional Statements in C programming.

What is a string?

As we all know 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.

Algorithm:-

Count Total Number of Words in a String

In this program, first, we will take the input string from the user. Then we will count the word from the string entered by the user. Now to count, we will pass that string to a for loop for counting.

Let us take the example program from the below code to count words.

Program:-

Output:-

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

 

  • s[200] = it will hold the string value.
  • i = it will hold the integer value.
  • Count = it will hold the integer value.

Input string from the user for the program.

Counting the word in the string.

Printing output number of the word.

C Program to Counting All Occurrence of a Character in a String

C Program to Counting All Occurrence of a Character in a String

In this tutorial, we will learn to create a C program that will Find the First Occurrence of a Character in a String in C programming

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.
  • Conditional Statements 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:-

Counting All Occurrence of a Character in a String

In this program, first, we will take the input string from the user. Then in the program, we will pass that string to a for loop and then will count all occurrences of a specific character in a String.

Let us take the example program from the below code for counting all occurrences of a Character in a String.

Program:-

Output:-

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

  • str[MAX_SIZE] = it will hold the string value.
  • toSearch = it will hold the character value.
  • i = it will hold the integer value.
  • flag = it will hold the integer value

Input string from the user for the program and take the input character from the user to search.

Counting the character in the string.

Printing output counting of the character.

C Program to Count Vowels, and Consonants in a String

C Program to Count Vowels, and Consonants in a String

In this tutorial, we will learn to create a C program that will Count the Vowels and Consonants in a String in C programming

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.

Algorithm:-

Count the Vowels and Consonants in a String

As we all know, the String is a collection of all characters. In strings, only one variable is declared which can store multiple values. First, will take the line of string from the user. Then will filter the number of vowels and the consonants from that strings. At last, we will print the result numbers.

With the help of this program, we can Count the Vowels and Consonants in a String.

Program Code:-

 

Output:-

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

  • s[1000] = it will hold the string value.
  • Vowels = it will hold the integer value for vowels.
  • Consonant  = it will hold the integer value for consonants.
  • i = it will hold the integer value.

Input strings from the user.

Filtering the vowels and the consonants from the string.

Printing output numbers of the vowels and the consonants.

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

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

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.

C Program to Find Frequency of each Character in a String

C Program to Find Frequency of each Character in a String

In this tutorial, we will learn to create a C program that will Find the frequency of each character in a String in C programming

Prerequisites

Before starting with this tutorial we assume that you are 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.
  • Conditional Statements in C programming.

What is the frequency of a string?

The frequency of a string means the number of occurrences of alphabets in the string. As we know the String is a collection of characters and words. The word is a collection of alphabets. For frequency, the letters are counted in the string individually and the result will show the statistics for the frequency.

Algorithm:-

Find the Frequency of each Character in a String

In this program first, we will take input string from the user. Then will find the Frequency of each Character in a String in that string by counting the occurrence of each character. Printing the frequency of that character.

Let us take the example program from the below code to find the Frequency of each Character in a String.

Program:-

 

Output:-

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

 

  • s[1000] = it will hold the string value.
  • j = it will hold the integer value.
  • i = it will hold the integer value.
  • k = it will hold the integer value.
  • flag = it will hold the integer value

Input string from the user for the program.

Finding the length of the string.

Finding the frequency in the characters in the string.

Printing output of the program.

C Program to find All Occurrence of a Character in a String

C Program to find All Occurrence of a Character in a String.

In this tutorial, we will learn to create a C program that will Find All the Occurrence of a Character in a String in C programming

Prerequisites

Before starting with this tutorial we assume that you are 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.
  • Conditional Statements in C programming.

What is the Occurrence of a string?

The frequency of a string means the number of occurrences of alphabets in the string. As we know the String is a collection of characters and words. The word is a collection of alphabets. For frequency, the letters are counted in the string individually and the result will show the statistics for the frequency.

Algorithm:-

Find All the Occurrence of a Character in a String

In this program first, we will take input string from the user. Then will find the Occurrence of each Character in a String in that string by counting the occurrence of each character. Printing the Occurrence of that character.

Let us take the example program from the below code to find the Occurrence of each Character in a String.

Program:-

Output:-

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

 

  • s[1000] = it will hold the string value.
  • j = it will hold the integer value.
  • i = it will hold the integer value.
  • k = it will hold the integer value.
  • flag = it will hold the integer value

Input string from the user for the program.

Finding the length of the string.

Finding the Occurrence of the characters in the string.

Printing output Occurrence of the characters.

C Program to find Characters in a String

C Program to find Characters in a String

In this tutorial, we will learn to create a C program that will Find the Characters in a String in C programming.

Prerequisites

Before starting with this tutorial we assume that you are 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.
  • Conditional Statements in C programming.

Character in a string:-

The finding of a character in a string means the number of occurrences of alphabets in the string. As we know the String is a collection of characters and words. The word is a collection of alphabets. For finding the characters, the letters are counted in the string individually and the result will show the statistics for the character.

Algorithm:-

Find the Character in a String:-

In this program first, we will take input string from the user. Then we will take the character to be searched from the user. Then will find the number of Characters in a String by counting the occurrence of that character. Printing the number of characters in that string.

Let us take the example program from the below code to find the Character in a String.

Program:-

Output:-

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

  • str[1000] = it will hold the string value.
  • chr = it will hold the string value.
  • flag = it will hold the integer value.

Input string from the user for the program.

Taking the input character from the user.

Finding the characters in the string.

Printing output number of the characters in the string.