Explanation
In this program, we need to replace all the spaces present in the string with a specific character.
String: Once in a blue moon  
String after replacing space with '-': Once-in-a-blue-moon   
One of the approach to accomplish this is by iterating through the string to find spaces. If spaces are present, then assign specific character in that index. Other approach is to use a built-in function replace function to replace space with a specific character.
Algorithm
- Define a string.
- Determine the character 'ch' through which spaces need to be replaced.
- Use replace function to replace space with 'ch' character.
Input:
char string[] = "Once in a blue moon"  
char ch = '-'  
Output:
String after replacing spaces with given character: Once-in-a-blue-moon
                                                                      
                            
Python
Output:
C
Output:
JAVA
Output:
C#
Output:
PHP
Output: