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


Please Help Members By Posting Answers For Below Questions

When should we use pointers in a c program?

614


What are examples of structures?

579


Write a code of a general series where the next element is the sum of last k terms.

577


Can you add pointers together? Why would you?

626


What is array within structure?

568






What is variable in c example?

583


Explain what is a 'locale'?

572


Write a program to print numbers from 1 to 100 without using loop in c?

621


In a byte, what is the maximum decimal number that you can accommodate?

613


#include int main(){ int i=10; int *ptr=&i; *ptr=(int *)20; printf("%d",i); return 0; } Output: 20 can anyone explain how came the output is 20

1243


What is the difference between #include

and #include “header file”?

538


How will you divide two numbers in a MACRO?

688


What is build process in c?

632


Why c language?

633


What is infinite loop?

615