Tag Archives: Function

Functions in C programming

A function is a collection of statements grouped together to do some specific task. In series of learning C programming, we already used many functions unknowingly. Functions such as - printf(), scanf(), sqrt(), pow() or the most important the main() function. Every C program has at least one function i.e. the main() function.

Continue reading Functions in C programming

C program to remove spaces, blanks from a string

Write a C program to remove extra spaces, blanks from a string. How to remove extra blank spaces, blanks from a given string using functions in C programming. Logic to remove extra white space characters from a string in C.

Example

Input

Input string: Learn     C      programming at  Codeforwin.

Output

String after removing extra blanks: 
"Learn C programming at Codeforwin"

Continue reading C program to remove spaces, blanks from a string

C program to replace all occurrences of a character in a string

Write a C program to replace all occurrence of a character with another in a string using function. How to replace all occurrences of a character with another in a string using functions in C programming. Logic to replace all occurrences of a character in given string.

Example

Input

Input string: I_love_learning_at_Codeforwin.
Input character to replace: _
Input character to replace with: -

Output

String after replacing '_' with '-': I-love-learning-at-Codeforwin

Continue reading C program to replace all occurrences of a character in a string

C program to replace last occurrence of a character in a string

Write a C program to replace last occurrence of a character with another in a given string. How to replace last occurrence of a character with another character in a given string using functions in C programming. Logic to replace last occurrence of a character with another in given string.

Example

Input

Input string: Do you love programming.
Input character to replace: .
Input character to replace with: ?

Output

String after replacing last '.' with '?' : Do you love programming?

Continue reading C program to replace last occurrence of a character in a string

C program to trim leading and trailing white spaces from a string

Write a C program to trim both leading and trailing white space characters in a string using loop. How to remove both leading and trailing white space characters in a string using loop in C programming. Logic to delete all leading and trailing white space characters from a given string in C.

Example

Input

Input string: "     Lots of leading and trailing spaces.     "

Output

String after removing leading and trailing white spaces: 
"Lots of leading and trailing spaces."

Continue reading C program to trim leading and trailing white spaces from a string

C program to trim trailing white spaces from a string

Write a C program to trim trailing/end white space characters in a string using loop. How to remove trailing blank space characters from a given string using loop in C programming. Logic to delete all trailing white space characters from a given string in C.

Example

Input

Input string: "Lots of trailing white spaces.      "

Output

String after removing trailing white spaces: 
"Lots of trailing white spaces."

Continue reading C program to trim trailing white spaces from a string

C program to trim leading white spaces from a string

Write a C program to trim leading white space characters from a given string using loop. How to remove leading white space characters from a given string using loop in C programming. Logic to remove leading/starting blank spaces from a given string in C programming.

Example

Input

Input string:       Lots of leading space.

Output

String after removing leading white spaces: 
Lots of leading space.

Continue reading C program to trim leading white spaces from a string

C program to remove all repeated characters in a string

Write a C program to remove all repeated characters in a string using loops. How to remove all duplicate characters from a string using for loop in C programming. Program to find and remove all duplicate characters in a string. Logic to remove all repeated character from string in C program.

Example

Input

Input string: Programming in C.

Output

String after removing duplicate characters: Progamin C.

Continue reading C program to remove all repeated characters in a string

C program to count occurrences of a word in a string

Write a C program to count occurrences of a word in a given string using loop. How to count total occurrences of a given word in a string using loop in C programming. Logic to count occurrences of a word in given string.

Example

Input

Input string: I love programming. I love Codeforwin.
Input word to search: love

Output

Total occurrences of 'love': 2

Continue reading C program to count occurrences of a word in a string