Program Discussion :: Strings
/ 60
Write a program to search duplicate characters in a string.
Answer:
#include
using namespace std;
int main()
{
char str[100];
coutstr;
cout
Asked In ::
Language:
Yousuf Hussain
29 Sep, 2019 12:33 AM
#include<iostream>
using namespace std;
int main()
{
char str[100];
cout<<"Enter the string : ";
cin>>str;
cout<<"\nYou Entered : ";
cout<<str;
int i=0,count=0;
while(str[i]!='\0')
{
count ;
i=i 1;
}
int flag =0;
for(int j=0;j<count;j )
{
for(int k=j 1;k<count;k )
{
if(str[j]==str[k])
{
cout<<"\n\nMatch Detected ! The character is : "<<str[j];
flag =1;
}
}
}
if(flag == 0)
{
cout<<"\n\nNo match detected !!!!"<<endl<<endl;
}
}