#include <iostream>
#include <string>
using namespace std;
int main()
{
string st;
char ch;
cout << "Enter your string : ";
int pos = -1;
cin >> st;
cout<<"Enter your character : ";
cin >> ch;
bool here = false;
for (int i = 0; i < 100; i++)
{
if (st[i] == ch)
{
pos = i;
break;
}
}
if (pos == -1)
{
cout << "Character is not found";
}
else
{
cout << "character found on position " << pos + 1;
}
cin.get();
cin.get();
return 0;
}
Comments
Leave a comment