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 <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;
}
Comments
Leave a comment