Tag Archives: c string programs

C Program to Reverse a Sentence Using Recursion

C Program to Reverse a Sentence Using Recursion

In this tutorial, we will learn to create a C program that will C Program to Reverse a Sentence Using Recursion 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.
  • Usage of Conditional statements.
  • Basic Input and Output function in C Programming.
  • Basic C programming.

Reverse a Sentence Using Recursion

In c programming, we have many predefined functions to workout with. The c language allows us to take long inputs from the users i.e. statements, these string values in the c programming language can be manipulated with the help of many predefined functions available for working.

The string manipulation functions can be applied to the variables or to be exact on the input statements. Available functions in a c programming language can make it easier to work with the strings.

With the help of these functions, we can reverse a string. Change a string to an upper case string or to a lower case string and many more.

Algorithm:-

Program to Reverse a sentence using the recursion:-

Output:-

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

  • c = string type variable that will hold the value of the input sentence.

Input strings from the user.

Scanning the input for the program.

Reverse printing function for the sentence.

Main Function of the program.

C Program to Concatenate Two Strings Using Pointers

C Program to Concatenate Two Strings Using Pointers

In this tutorial, we will learn to create a C program that will Concatenate Two Strings Using Pointers 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.
  • While loop in c programming.

Concatenate Two Strings Using Pointers

As we all know the String is a collection of character data types. In strings, only one variable is declared which can store multiple values. First will take the number of elements of string 1 from the user. Then will take the number of elements of string 2 from the user. Then will take the elements from the user for string 1 and as well as for string 2. And concatenate them using the pointer.

With the help of this program, we can Concatenate Two Strings Using Pointers.

Algorithm:-

Program to Concatenate Two Strings Using Pointers:-

 

Output:-

The above program we have first initialize the required variable.

  • string1[20] = it will hold the string value.
  • string2[20] = it will hold the string value.
  • i = it will hold the integer value.
  • j = it will hold the integer value.
  • *str1 = pointer type variable 1.
  • *str2 = pointer type variable 2.

Input strings from the user.

While loop body for concatenating the strings using the pointers and printing the concatenated string.

 

C Program to Compare Two Strings Without Using strcmp

C Program to Compare Two Strings Without Using strcmp

In this tutorial, we will learn to create a C program that will Compare Two Strings Without Using strcmp 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 of C programming.
  • For loop and its concepts in C Programming.
  • Conditional Statements in C Programming.

Compare Two Strings Without Using strcmp

As we all know the String is a collection of character data types. In strings, only one variable is declared which can store multiple values. First will take the elements of string 1 from the user. Then will take the elements of string 2 from the user. Then will compare the two taken strings without using the predefined functions. i.e. compare them without using the strcmp function.

With the help of this program, we can Compare Two Strings Without Using strcmp

Algorithm:-

Program to Compare Two Strings Without Using strcmp:-

 

 

Output:-

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

  • string1[100] = it will hold the string value.
  • string2[100] = it will hold the string value.
  • i = it will hod the integer value that will control the for loop

Taking Input string 1 from the user.

Taking Input string 2 from the user.

Printing Output without using the strcmp function which is available in c language.

C Program to Concatenate Two Strings Without Using strcat

C Program to Concatenate Two Strings Without Using strcat

In this tutorial, we will learn to create a C program that will Concatenate Two Strings Without Using strcat 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.
  • While loop in c programming.

Concatenate Two Strings Without Using strcat.

As we all know the String is a collection of character data types. In strings, only one variable is declared which can store multiple values. First will take the number of elements of string 1 from the user. Then will take the number of elements of string 2 from the user. Then will take the elements from the user for string 1 and as well as for string 2. And concatenate them using the Without Using strcat .

With the help of this program, we can Concatenate Two Strings Without Using strcat

Algorithm:-

Program to Concatenate Two Strings Using Without Using strcat :-

 

Output:-

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

  • string1[100] = it will hold the string value.
  • string2[100] = it will hold the string value.
  • i = it will hold the integer value.
  • j = it will hold the integer value.
  • string3 = it will hold the string value.

Input strings.

While loop body for the first string to another.

While loop body for the second string to another.

Printing Output.

C Program to Sort a String in Alphabetical Order

C Program to Sort a String in Alphabetical Order

In this tutorial, we will learn to create a C program that will Sort a String in Alphabetical Order 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.
  • Concepts of for loop.
  • Using String functions of c language.

Sort a String in Alphabetical Order

As we all know the String is a collection of character data types. In strings, only one variable is declared which can store multiple values. First will take the string from the user. Then will check the number of elements of the string. Now we will arrange that string in alphabetical order.

With the help of this program, we can Sort a String in Alphabetical Order

Algorithm:-

Program to Sort a String in Alphabetical Order:-

 

 

Output:-

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

  • string1[] = it will hold the string value.
  • flag = it will hold the temporary value.
  • i = it will hold the integer value for the loop.
  • j = it will hold the integer value for the loop.
  • n = it will hold the size of the string.

Including the required header files.

Taking Input string.

Printing before the alphabetical order.

Printing a String in Alphabetical Order.

Program Code for arranging.

C Program to Concatenate Two Strings Using strcat

C Program to Concatenate Two Strings Using strcat

In this tutorial, we will learn to create a C program that will Concatenate Two Strings Using strcat 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.
  • Using String functions of c language.

Concatenate Two Strings Using strcat

As we all know the String is a collection of character data types. In strings, only one variable is declared which can store multiple values. First will take the number of elements of string 1 from the user. Then will take the number of elements of string 2 from the user. Then will take the elements from the user for string 1 and as well as for string 2. And concatenate them using the strcat function.

With the help of this program, we can Concatenate Two Strings Using strcat

Algorithm:-

Program to Concatenate Two Strings Using strcat:-

 

 

Output:-

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

  • string1[100] = it will hold the string value.
  • string2[100] = it will hold the string value.

Taking Input string 1 from the user.

Taking Input string 2 from the user.

Printing Output using the strcat function which is available in c language.

C Program to Copy String Without Using strcpy

C Program to Copy String Without Using strcpy

In this tutorial, we will learn to create a C program that will Copy String Without Using strcpy 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.
  • Concepts of for loop.
  • Using String functions of c language.

Copy String Without Using strcpy

As we all know the String is a collection of character data types. In strings, only one variable is declared which can store multiple values. First will take the string from the user. Then will pass that string to a for loop for copying. The C programming language has many pre-defined functions for string manipulation. but in today’s tutorial, we will do without using strcpy().

With the help of this program, we can Copy String Without Using strcpy

Algorithm:-

Program to Copy String Without Using strcpy:-

 

Output:-

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

  • string1[100] = it will hold the string value.
  • string2[100] = it will hold the string value.
  • i = it will hold the integer value for the loop.

Taking Input string from the user.

Reading the input string from the user.

Copying the string with the help of for loop without using strcpy() function.

Printing output copied string2 without strcpy.

C Program to Find the Length of a String

C Program to Find the Length of a String.

In this tutorial, we will learn to create a C program that will Find the Length of 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.
  • Concepts of for loop.
  • Using String functions of c language.

Find the Length of a String.

As we all know the String is a collection of character data types. In strings, only one variable is declared which can store multiple values. First will take the string from the user. Then will pass that string to a for loop for copying. The C programming language has many pre-defined functions for string manipulation. but in today’s tutorial, we will do it with the help of for loop.

With the help of this program, we can Find the Length of a String.

Algorithm:-

Program to Find the Length of a String:-

 

Output:-

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

  • string1[100] = it will hold the string value.
  • string2[100] = it will hold the string value.
  • i = it will hold the integer value for the loop.

Taking input string from the user.

Reading the input string from the user/Storing the input from the user.

Find the length using for loop of a given string.

Printing the length of the string

C Program to Remove all Characters in a String Except Alphabet

C Program to Remove all Characters in a String Except Alphabet

In this tutorial, we will learn to create a C program that will Remove all Characters in a String Except Alphabet 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.
  • While loop in c programming.

Remove all Characters in a String Except Alphabet.

As we all know the String is a collection of character data types. In strings, only one variable is declared which can store multiple values. First will take the string from the user. Then will pass that string to a for loop to filter the numbers from that string.

With the help of this program, we can Remove all Characters in a String Except Alphabet.

Algorithm:-

 

Program to Remove all Characters in a String Except Alphabet:-

 

 

Output:-

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

  • line[150] = it will hold the string value.
  • i  = it will hold the integer value for the loop.
  • j = it will hold the integer value for the loop.

Taking input string from the user.

Scanning the input string from the user.

Storing the string and extracting only string data by for loop.

Printing output of the program.

C Program to Count the Number of Vowels, Consonants and so on

C Program to Count the Number of Vowels, Consonants and so on

In this tutorial, we will learn to create a C program that will Count the Number of Vowels, Consonants, and so on 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.

Count the Number of Vowels, Consonants, and so on

As we all know the String is a collection of character data types. In strings, only one variable is declared which can store multiple values. First will take the line of string from the user. Then will take the number of elements in the string, Now we will filter the string using the c programming.

With the help of this program, we can Count the Number of Vowels, Consonants, and so on.

Algorithm:-

Program to Count the Number of Vowels, Consonants, and so on:-

 

Output:-

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

  • line[150] = it will hold the string value.
  • vowels = it will hold the integer value for vowels.
  • consonant  = it will hold the integer value for consonants.
  • digit= it will hold the integer value for numbers.
  • space= it will hold the integer value for spaces.

Input strings from the user.

Assigning blank value to all to prevent garbage value.

Calculating the size of the string.

Filtering vowels from the string.

consonants filtering from the string.

filtering numbers from the string.

filtering white spaces from the string.

Printing output.