Question

write program in C that print the continuous sub strings of a given string so if...

write program in C that print the continuous sub strings of a given string so if the user enter "ABC" the output should be "A, B, C, AB, BC"

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<stdio.h>
int main()
{
  
   char s[100];
   //reading input
   printf("Enter string:");
   scanf("%s",&s);
   int n;
   for(n=0;s[n]!='\0';n++);//finding length of string entered
   //displaying ouput
  
   for(int i=1;i<n;i++)
   {
       for(int j=0;j<(n-(i-1));j++)
       {
           int k =j;
          
           for(int c=0;c<i;c++,k++)
           {
               printf("%c",s[k]);
           }  
           printf("\n");  
       }  
   }
   return 0;
}

output:

Enter string:ABC
A
B
C
AB
BC


Process exited normally.
Press any key to continue . . .


//PLS give a thumbs up if you find this helpful, it helps me alot, thanks.

Add a comment
Know the answer?
Add Answer to:
write program in C that print the continuous sub strings of a given string so if...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT