Answer to Question #191877 in C++ for Utkarsh

Question #191877

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-11T17:24:00-0400
#include <iostream>
#include <string>
using namespace std;


int main()
{
	string test;
	cout << "Enter string : ";
	cin >> test;
	for (int i = 0; i < test.length(); i++) 
	{
		for (int j = 0; j <= i; j++)
		{
			cout << test[j];
		}
		cout << endl;
	}
	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