<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

No data
He led the Lightning with 17 points in 17 playoff games last season, and his 58 postseason Wholesale ...
No data
No data
No data
Looks like it's going to take more than a well-enforced curfew to help this team pick up some ...
No data
No data
No data
Residents selected to purchase tickets this year will receive Mobile Ticketing instructions along ...
No data
No data

Leave a Reply

Your email address will not be published. Required fields are marked *

Skip to toolbar