Write a program in C++ to check the occurence of any character in a string
#include<iostream.h>
#include<conio.h> void main() { char ch[10],ch1; int i,j=0; clrscr(); cout<<”Enter any string”; cin>>ch; cout<<”Enter any character for check”; cin>>ch1; for(i=0;ch[i]!=’\o’;i++) { If(ch[i]==ch1) { j++; } } cout<<ch1<<” Is used “<<j<< “times”; getch(); } |
|