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 ?    6 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is quality center? How many built in tables does quality center have?

796


What r the things,u prefer and prepare before starting testing?

1769


What is defect cascading in software testing?

721


What is difference between cmmi and cmm levels?

679


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

1614






What's the relationship between environment reality and test phases?

891


Write notes on apparel testing equipments.

763


Hi Friends, Just One Month Back I was Join in Small Company as a Testing Eng.I have Six Month Exp. In this Company all my team memb.r fresher & PM give responsibility on us to prepare all require QC doc. for our new project.So I need ur help in this matter .How Can I start my work and Which Doc.I start to collect & From Where I get Detail Information all abt these thing. Thanks to all friends who give reply to this. Suyog

1416


In usability testing we check spelling, content, look and feel, color combination, link or menu navigation? please let me know more about usability testing.

1550


When we use integration testing for any new system so why we required system testing.

1542


What is AGP?what is setup.inf?What are the ways to install driver?

1777


what is traceability matrix and its usefulness

3408


Have you prepared traceability matrix and how to prepare it?

1589


Can any one give a summary of testing a territory management system? what would be the test scenarios, few test cases. how it works.

1521


Tell some examples of bug severity and bug priority?

622