void main()
{
 int i=0,j=0,k=0,count=0,l=0,k1=0;
 char a[80],b[80];
 clrscr();
 printf("
Enter main string:-
");
 gets(a);
 printf("
Enter sub-string:-
");
 gets(b);
 l=strlen(b);
 while (a[i]!=EOF)
 {
 if (a[i]==b[j])
 {
 i++;
 j++;
 k1=1;
 if (j==l)
 {
 j=0;
 k=1;
 count=count+1;
 }
 }
 else
 {
 if (k1==1)
 {
 j=0;
 k1=0;
 }
 else
 i++;
 }
 }
 if (k==1)
 {
 printf("
The given sub-string is present in the main string.");
 printf("
It is present %d times.",count);
 }
 else
 {
 if (k==0)
 printf("
The given sub-string is not present in the main string.");
 }
 getch();
}