Write a program that inputs an integer and a character. The output should be a pyramid of the character and extending the width specified by the integer.
For example if the integer is 11 and the character is an asterisk ‘*’
*
***
*****
*******
*********
***********
#include <iostream.h>
void main()
{
int
a,b,s;
char c;
cout<<"Enter
Size : ";
cin>>s;
cout<<"Enter
character : ";
cin>>c;
for(a=s;
a>=0; a--)
{
if(a%2==0)
{
for(b=1;
b<=a; b++)
cout<<"
";
for(b=0;
b<s-a; b++)
cout<<c<<"
";
cout<<endl;
}
}
}
{[['
']]}

0 comments:
Post a Comment
Click to see the code!
To insert emoticon you must added at least one space before the code.