Sample output:
Input the string : this a test
Input the substring to be search : test
The substring exists in the string.
1. [K/U: /2] Explain the logic that you may apply to complete the code.
2. [T: /2] Create a flowchart based in the program requirement.
3. [A: /2] Write the missing code.
4. [C: /2] Explain the functions used in the code.
#include <stdio.h>
void main()
{
char str[80],search[20];
int c1=0,c2=0,i,j,flg;
printf("Input the string : ");
fgets(str, sizeof str, stdin);
printf("Input the substring to be search : ");
fgets(search, sizeof search, stdin);
while (str[c1]!='\0')
c1++;
c1--;
while (search[c2]!='\0')
c2++;
c2--;
for(i=0;i<=c1-c2;i++)
{
//missing code
}
if (flg==1)
printf("The substring exists in the string.\n\n");
else
printf("The substring is not exists in the string. \n\n");
}