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 ? | 10 Yes | 3 No |
Post New Answer View All Answers
What is the difference between baseline and traceability matrix?
What exactly is quality control?
What is a defect?
can any one send sample test cases for database testing by taking an example? also leave emailid please. thanks (very urgent)
What are the different strategies for rollout to end users?
How to derive test data from the design documents?
what is meant by application server and its functions?
wat is meant by frontend and backend testing
HI, This question is Investment Banking domain related Question. I was asked in an Interview to tell the 5 test cases for Equity,Bond,Futures and options. Please help.. Pragya
How we will test ubercate
How to do manual testing of a E-insurance project (end to end process)
Difference between smoke and sanity testing
What do you understand by usability testing?
Can any one explain me about hybrid integration testing? and what is interface in integration testing? thanks in advance...... regards, MurthySharma.Manchella
Can some one help me writing a manual test case for email applications like yahoo i need for www.everonn.com