text: Program to print all substrings of a given string | C program for the above approach ; outermost for loop this is for the selection of starting point ; 2 nd for loop is for selection of ending point ; 3 rd loop is for printing from starting point to ending point ; changing the line after printing from starting point to ending point ; Driver Code ; calling the method to print the substring
code: #include <stdio.h> NEW_LINE void printSubstrings ( char str [ ] ) { for ( int start = 0 ; str [ start ] != ' \0' ; start ++ ) { for ( int end = start ; str [ end ] != ' \0' ; end ++ ) { for ( int i = start ; i <= end ; i ++ ) { printf ( " % c " , str [ i ] ) ; } printf ( " STRNEWLINE " ) ; } } } int main ( ) { char str [ ] = { ' a ' , ' b ' , ' c ' , ' d ' , ' \0' } ; printSubstrings ( str ) ; return 0 ; }