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
When should we use pointers in a c program?
What are examples of structures?
Write a code of a general series where the next element is the sum of last k terms.
Can you add pointers together? Why would you?
What is array within structure?
What is variable in c example?
Explain what is a 'locale'?
Write a program to print numbers from 1 to 100 without using loop in c?
In a byte, what is the maximum decimal number that you can accommodate?
#include
What is the difference between #include
How will you divide two numbers in a MACRO?
What is build process in c?
Why c language?
What is infinite loop?