Q. write a C program to accept a string from user and after that accept a single character from user and search whether this character include in string or not if is is include then find out the position of character and also calculate, how many times character repeat?

For example:

Entered string : This is C programming
Entered character for search: p

Position of p in string : 11
Repeation of p in string : 1

Ans.

/*c program for search character and if is include then how many times present in string*/
#include<stdio.h>
#include<conio.h>
int searchChar(char [], char);
int repeatChar(char [], char);
int main()
{
 char str[100];
 char search;
 int count,repeat,posi;
 printf("Enter any string : ");
 for(count=0; ((str[count]=getchar())!=
); ++count);
 str[count+1]=


Categories: , , , , , , , , ,

Leave a Reply