part 4 C A sample run should appear on the screen like the t
part 4
C++
Solution
#include <iostream>
#include <string>
#include<stdio.h>
using namespace std;
int main ()
{
string phrase;
char c;
int i=0;
static int oc=0;
cout << \"Enter phrase:\"<<endl;
getline (cin,phrase);
cout<<\"Enter Letter:\"<<endl;
c=getchar();
//Below code is for occurence of Letter in String using case-sensitive
while(phrase[i]!=\'\\0\')
{
if(c==phrase[i])
{
oc++;
}
i++;
}
cout << \"The Letter \\\"\"<<c<<\"\\\" Occured\" <<oc<< \"times\"<<endl;
return 0;
}
Hi friend, I have written code for find the number of occurence of Letter in user entered String (matching contain case-sensitivity because in your example you mentioned you are counting occurence of small g).But if you need your programme ignore case-sensitivity for counting the occurence of letter please write me.
Thanks....
