Logo 
Search:

C++ Programming Forum

Ask Question   UnAnswered
Home » Forum » C++ Programming       RSS Feeds

Print String as Right Triangle

  Asked By: Lindy    Date: Feb 23    Category: C++ Programming    Views: 30843
  

I am completely at a loss for how to solve this... Please help.

Read a set of characters (string) from the standard input device (kbd), and render the string in the right triangle form as shown below. For instance, if the user enters the string "Program", its right triangle for the string will
looks like the following.

Program
Progra
Progr
Prog
Pro
Pr
P

margorP
argorP
rgorP
gorP
orP
rP
P

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Muhammad Abdullah     Answered On: May 02


//Hope this Helps
#include<iostream>
using namespace std;
int main()
{
	int size = 0,u=0;
	cout<<"Enter The Size word ";
	cin>>size;
	u=size;
	
	char word[size];
	cout<<"Enter the word to change it into triangle ";
	cin>>word;
	for(int i=0;i<size;i++)
	{
		cout<<word<<endl;
		u = u - 1;
		word[u] = '\0';
	}
	system("pause");
}

 
Didn't find what you were looking for? Find more on Print String as Right Triangle Or get search suggestion and latest updates.




Tagged: