3. Program to print all possible substrings.
ex: String
S
St
Str
Stri
Strin
String
t
tr
tri
trin
tring
r
Answer Posted / siraj
#include<stdio.h>
int main()
{
char a[10]="String";
substringTest(a);
getch();
return 0;
}
void substringTest(char *a)
{
int i,j,n,k;
for(n=0; a[n]!='\0'; n++) {}
// n=strlng(a);
for(i=0; i<n; i++)
{
for(j=i; j<n; j++)
{
for(k=i; k<j+1; k++)
{
printf("%c",a[k]);
}
printf("\n");
}
}
}
| Is This Answer Correct ? | 1 Yes | 2 No |
Post New Answer View All Answers
Explain what is the advantage of a random access file?
Which operators cannot be overloaded a) Sizeof b) .* c) :: d) all of the above
What is the difference between array and pointer in c?
What are pointers? Why are they used?
largest Of three Number using without if condition?
Function calling procedures? and their differences? Why should one go for Call by Reference?
Is it possible to use curly brackets ({}) to enclose single line code in c program?
What is #include conio h?
How can I recover the file name given an open stream or file descriptor?
How can my program discover the complete pathname to the executable from which it was invoked?
number of times a digit is present in a number
Define Spanning-Tree Protocol (STP)
What do you mean by command line argument?
How can I get random integers in a certain range?
What do you mean by keywords in c?