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

What is masking?

629


What are pointers? What are stacks and queues?

571


What is a const pointer in c?

658


What is a ternary operator in c?

646


Explain what are the different data types in c?

745






Which is best book for data structures in c?

588


write a c program for swapping two strings using pointer

2085


What is structure padding in c?

616


How arrays can be passed to a user defined function

570


what do you mean by enumeration constant?

588


How can I find out the size of a file, prior to reading it in?

610


What are the different properties of variable number of arguments?

657


What is conio h in c?

614


Why do we need volatile in c?

737


the factorial of non-negative integer n is written n! and is defined as follows: n!=n*(n-1)*(n-2)........1(for values of n greater than or equal to 1 and n!=1(for n=0) Perform the following 1.write a c program that reads a non-negative integer and computes and prints its factorial. 2. write a C program that estimates the value of the mathematical constant e by using the formula: e=1+1/!+1/2!+1/3!+.... 3. write a c program the computes the value ex by using the formula ex=1+x/1!+xsquare/2!+xcube/3!+....

22180