3. Program to print all possible substrings.

ex: String
S
St
Str
Stri
Strin
String
t
tr
tri
trin
tring
r

Answers were Sorted based on User's Feedback



3. Program to print all possible substrings. ex: String S St ..

Answer / rafiq

#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
int i,j,n,k;
char a[10]="String";
i=0;
n=strlen(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");
}

}

getch();
}

Is This Answer Correct ?    51 Yes 23 No

3. Program to print all possible substrings. ex: String S St ..

Answer / 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

3. Program to print all possible substrings. ex: String S St ..

Answer / nik

#include<stdio.h>
#include<conio.h>
#include<string.h>
int main(){
int i,j=0,k=0,n;
char str[50],str1[25],str2[25],temp;
puts("Enter String");
gets(str);
n=strlen(str);
for(i=0;i<n;i++){
for(j=i;j<n;j++){
for(k=j;k<n;k++){

printf("%c",str[k]);
}

printf("\n");
}

printf("\n");
}
getch();
}

Is This Answer Correct ?    15 Yes 21 No

Post New Answer

More C Interview Questions

State the difference between x3 and x[3].

0 Answers   Aricent,


Explain zero based addressing.

0 Answers  


What is #line?

0 Answers  


What is f'n in math?

0 Answers  


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

0 Answers   Aspiring Minds,






An array name contains base address of the array. Can we change the base address of the array?

4 Answers   NMIMS, Wipro,


Program to swap the any two elements in an array containing N number of elements?

1 Answers   Bosch, Glenwood, Ugam Solutions,


what is the meaning of java that is (J A V A) full form of JAVA

71 Answers   AKS University, Bhel, BNL, BPO, HCL, Peacecon,


Write a program of prime number using recursion.

0 Answers   Aspiring Minds,


Write a c program to read a positive number and display it in words.? ex: 123=one two three help me....

2 Answers  


Derive the complexity expression for AVL tree?

1 Answers  


What kind of structure is a house?

0 Answers  


Categories