Answer to Question #191864 in C++ for Sharath kumar

Question #191864

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



1
Expert's answer
2021-05-11T07:09:26-0400
#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;
}




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment