## Count number of equal pairs in a String in C++

Here we will first understand how to count number of equal pairs in a String using two methods, then we will write a C++ programs to implement these solutions. Given: A string s Problem: To find the number of equal pairs in the string s. Note: Pairs (s[i], s[j]), (s[j], s[i]), (s[i], s[i]), (s[j], s[j]) should be … Read more

## Number of substrings of binary string containing K ones

In this post we will write a program in C++ to count the number of substrings of a binary string containing K ones, first we will discuss the problem with examples and then implement the solution in C++. Given: A binary string of length N and an integer K. Problem: Find out how many substrings of the given … Read more

## Write a Program to concatenate strings in C++

Here we will write a simple program to Concatenate Strings in C++ without using any library functions. Let’s follow the simple approach below: Input 2 strings. Go to end of one string and add second after it. put NULL ” at the end of the string. Let’s write the C++ code for the same. Checkout … Read more

## Program to find frequency of characters in a string C++

#### Finding frequency of characters in a string C++ is like:

Let the string is: I am Software engineer

The Frequency if character ‘e’ in this String is: 4

## CODE:

```#include <iostream>
#include <cstring>
using namespace std;

int main()
{
char c[30],ch;
int i,count=0;
cout << "Enter a string: ";
cin.getline(c, 1000);
cout << "Enter a character to find frequency: ";
cin >> ch;
for(i=0;c[i]!='';++i)
{
if(ch==c[i])
count++;
}
cout << "Frequency of " << ch << " = " << count;
return 0;
}```

## PROGRAM:

```#include<iostream>
using namespace std;

int main( )
{

char str[80];
cout<<"Enter a string:";
gets(str);

for(int i=0;str[i]!='';i++)
str[i] = (str[i]>='a' && str[i]<='z')?(str[i]-32):str[i];
cout<<str;

return 0;
}```

## PROGRAM:

```#include<iostream>
using namespace std;

int main( )
{

char str[80];
cout<<"Enter a string:";
gets(str);

for(int i=0;str[i]!='';i++)
str[i] = (str[i]>='A' && str[i]<='Z')?(str[i]+32):str[i];

cout<<str;

return 0;
}```