Write a program to check if an alphabet occurs twice continuously in an input string in java.
For ex Input:Rabbit
Output: Yes
b-2
Answers
Answered by
1
#include <bits/stdc++.h>
using namespace std:
int main() {
string str;
int count = 0;
cin >> str;
for (int i = 0; i<str.length()-1; i++) {
if (str.at(i)==str.at(i+1))
count++;
}
if (count>0)
cout << "Yes" << endl;
else
cout << "No" << endl;
return 0;
}
Similar questions
Physics,
6 months ago
Science,
6 months ago
Business Studies,
6 months ago
Biology,
11 months ago
Math,
11 months ago
Social Sciences,
1 year ago
Chemistry,
1 year ago