Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


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

WHAT IS THE DIFFERENCE BETWEEN malloc() and calloc() in c file management?

28 Answers   3D PLM, Code Studio, Deltech, IBM,


Explain what is the purpose of "extern" keyword in a function declaration?

0 Answers  


What is the difference between test design and test case design?

0 Answers  


#define d 10+10 main() { printf("%d",d*d); }

6 Answers  


void swap(int a,int b) { a=a+b; b=a-b; a=a-b; } in this code always gives the same result for all case

9 Answers   Accenture, TCS,






write a program to fined second smallest and largest element in a given series of elements (without sorting)

9 Answers   Yahoo,


Define VARIABLE?

0 Answers   ADP,


main() { float a=3.2e40; printf("%d",a); }

9 Answers   Satyam,


How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?

0 Answers  


how to use enum datatype?Please explain me?

3 Answers   Excel,


Is it fine to write void main () or main () in c?

0 Answers  


write a program whose output will be- 1 12 123 1234

10 Answers  






Categories