#include<iostream> #include<cctype> using namespace std; void stringupper(char*)
ID: 3610868 • Letter: #
Question
#include<iostream>
#include<cctype>
using namespace std;
void stringupper(char*);
int countchar(const char*,char)
int main()
{
char strgl[]="fdsgnsdfgsdg";
char *ptr_strgl=strgl,ch='G';
stringupper(ptr_strgl);
cout<<"The letter"<<ch<<" appears"
<<countchar(ptr_strgl,ch)<<" times in the string "
<<ptr_strgl<<endl;
return 0;
}
int countchar(const char*ptr_strg, char ch)
{
int cnt(0);
while(*ptr_strg)
{
if(*ptr_strg == ch)
cnt++;
ptr_strg++;
}
return cnt;
}
Explanation / Answer
#include #include #include main() { int found = 0; char data[30]; char *data_ptr =data; char choice; char *choice_ptr; choice_ptr = &choice; coutdata; coutchoice; for(int i = 0; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.