design a black box test suite for a program that accepts
two strings and checks if the first string is a substring
of the second string and displays the number of times the
first string occurs in the second string.

Answer Posted / bhupndra

#include<stdio.h>
#include<conio.h>

int main()
{

int i=0,j=0,k=0,count=0,l=0,k1=0;
char a[80],b[80];

clrscr();
printf("\nEnter main string:-\n");
gets(a);
printf("\nEnter sub-string:-\n");
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("\n\nThe given sub-string is present in the main
string.");
printf("\nIt is present %d times.",count);
}

else
{
if (k==0)
printf("\n\nThe given sub-string is not present in the
main string.");
}

}

Is This Answer Correct ?    9 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the disadvantages of manual testing?

752


In how many ways you perform batchtesting ?

1622


Write 10 test scenarios to test remember me checkbox present in login window

1095


What was a problem you had in your previous assignment (testing if possible)? How did you resolve it?

1691


what is scrum how with ex?

1716






Can some one help me writing a manual test case for email applications like yahoo i need for www.everonn.com

1621


Tell me some Adhoc testing scenarios of ebay (online auction product)?

3508


What is a testbed in manual testing?

1060


Write the test cases for godaddy home page

1354


i want manual and automation test cases and interview questions

1785


what are questions asked in TCS for database tester (sqlserver)?ay idea

2558


How do u determine,what to be tested?

1707


if yahoo ceo asks you to do performance testing for yahoo site, what are the inputs you ask from them?

1731


can any body tell me what is the process of between after getting a documents and testcase writing.

1629


Hi i am looking for Test Engineer Job, i have done the course, but i don't have work experience on it, Is it So important to have real time Exp or knowledge is enough? and please let me know like how i can improve for the interview. You can send me a mail on this id: rashmi_vastred@yahoo.co.in

1725