Write a program in C++ that asks the user for a word or phrase. Do not use i/o s
ID: 3684052 • Letter: W
Question
Write a program in C++ that asks the user for a word or phrase. Do not use i/o stream, use only basic stdio.h funtions and standard string functions.
It then creates an inverse triange with said word or phrase. For example : the word "apple"
a p p l e
a p p l
a p p
a p
a
Line 1 = full phrase with a space after each letter
Line 2 = starts with a space, then has a space between each letter, then omits last letter
line 3 = starts with 2 spaces, space between each letter, omits last 2 letters
line n = starts witn n-1 spaces, space between each letter, omits last n - 1 letter.
Explanation / Answer
#include<stdio.h>
#include<conio.h>
int main()
{
char demoString[50];
demoString= "apple";
int size;
size=strlen(demoString);
cout<<"pattern in reverse";
for(int i=1;i<size;i++)
{
for(int k=0;k<size-1;k++)
{
cout<<demoString[k];
while(i)
{
cout<<" ";
}
}
cout<<" ";
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.