Question :Develop a C++ code to get a string for the following pattern display using io manipulators.
Test case 1: Input: KSRCT
Output:
K
KS
KSR
KSRC
KSRCT
#include<stdio.h>
int main()
{
char str[20];
printf("Enter a string: ");
scanf("%[^\n]",str);
for(int i=0; str[i]!='\0'; i++)
{
for(int j=0; j<=i; j++)
{
printf("%c ", str[j]);
}
printf("\n");
}
return 0;
}
Comments
Leave a comment