<pre>
<strong>Program for searching a character in a string.</strong>
<p>/*Program for searching a character in a string*/

#include<stdio.h>
#include<conio.h>
void main()
{
char str[20],ch;
int cnt=0,i;
clrscr();
printf(“nnntt Program for searching a character in a string”);
printf(“nnnttt Enter a string = “);
scanf(“%s”,&str);
printf(“nttt Enter the character to search = “);
flushall();
scanf(“%c”,&ch);
for(i=0;str[i]!=”;i++)
{
if(str[i]==ch)
cnt++;
}
if(cnt==0)
printf(“nnttt The character ‘%c’ is not found in the string…”,ch);
else
printf(“nnttThe character ‘%c’ is occurring %d times in the string.”,ch,cnt);
getch();
}
</p>
</pre>

Related Posts

आज से विश्व कप का आगाज: रिजर्व-डे से लेकर सुपरओवर तक, 17 पॉइंट्स में जानें इस टूर्नामेंट से जुड़ी हर ...
worldeye
October 6, 2023
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore ...
worldeye
January 23, 2022
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore ...
worldeye
January 23, 2022