Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

#include<iostream> #include<string> #include<cctype> using namespace std; int ma

ID: 3611018 • Letter: #

Question

#include<iostream>

#include<string>

#include<cctype>

using namespace std;

int main()

{

int found = 0;

char data[30];

char *data_ptr = data;

char choice;

char *choice_ptr;

choice_ptr = &choice;

cout << "Enter required string:";

cin >> data;

cout<<"Enter character for searching:";

cin>>choice;

for(inti = 0; i < strlen(data); i++)

{

if(*data_ptr == choice)

{

found++;

}

else if(*data_ptr ==toupper(*choice_ptr))

{

found++;

}

*data_ptr++;

}

if(found == 0)

{

cout<<"Your choosen character is notfound."<<endl;

}

cout<<"Your choosen character is found"<<found<<" time is thestring. ";

system("pause");

return 0;

}

Explanation / Answer


//Above code is compiled in Dev c++, whichcompiler you are using ?
//Hope this will helpyou.
//Don't forget to rateit.


int repeat(char *ptr)
{
int i;
char r_char[100];
char *data_ptr=ptr+1;
int r_count=0,count=0;
char prev=ptr[0];
int len=(int)strlen(ptr);
for(int i = 1; i < len; i++)
{
if(prev == *data_ptr)
{
count++;
if(count==1){
r_char[r_count]=prev;
r_count++;
}
data_ptr++;
continue;
}
else
prev=*data_ptr;
count=0;
data_ptr++;
}