CPP Program to display Character Parallelogram

This simple Cpp program takes any word from the standard input string and display that string in the form of character Parallelogram. The program was tried and tested on Windows 10 using Dev CPP IDE.

<pre>

/*    program to generate parallogram text
made by        : rakesh kumar
T
T E
T E S
T E S T
T E S T I
T E S T I N
T E S T I N G
E S T I N G
S T I N G
T I N G
I N G
N G
G

*/

#include<iostream>
#include<conio.h>
#include<string.h>
#include<iomanip>
using namespace std;
int main()
{
char str[100];
int i,j,k;

cout<<“\n Enter any string : “;
cin>>str;

//processing phase
for(i=0;i<strlen(str);i++)
{
for(j=1;j<strlen(str)-i;j++)
cout<<setw(2)<<“”;
for(k=0;k<=i;k++)
cout<<setw(2)<<str[k];
cout<<endl;
}

for(i=0;i<strlen(str);i++)
{
for(j=i+1;j<strlen(str);j++)
cout<<setw(2)<<str[j];
cout<<endl;
}

return 0;
}

</pre>

Output of the above code is as follows

C++ Program to generate paralleogream of chars
CPP program for character parallelogram output
%d bloggers like this: