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
What is masking?
What are pointers? What are stacks and queues?
What is a const pointer in c?
What is a ternary operator in c?
Explain what are the different data types in c?
Which is best book for data structures in c?
write a c program for swapping two strings using pointer
What is structure padding in c?
How arrays can be passed to a user defined function
what do you mean by enumeration constant?
How can I find out the size of a file, prior to reading it in?
What are the different properties of variable number of arguments?
What is conio h in c?
Why do we need volatile in c?
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!+....