Write a 'C' Program to accept a string from user and generate following pattern (e.g. input is string "abcd")
#includevoid main() { int i,j,length; char str[25]; clrscr(); printf("ENTER ANY STRING ::>"); scanf("%s",str); length = strlen(str); for(i = 0 ; i < length ; i++) { for(j = 0 ; j <= i ; j++) { printf("%c ",str[j]); } printf("\n"); } for(i = length - 2 ; i >= 0 ; i--) { for(j = 0 ; j <= i ; j++) { printf("%c ",str[j]); } printf("\n"); } getch(); } /*OUTPUT: ENTER ANY STRING ::> abcd a a b a b c a b c d a b c a b a ENTER ANY STRING ::>SANTOSH S S A S A N S A N T S A N T O S A N T O S S A N T O S H S A N T O S S A N T O S A N T S A N S A S */
Write a 'C' Program to accept a string from user and generate following pattern (e.g. input is string "abcd")
Reviewed by
on
April 24, 2015
Rating: