// Program to print an ascending triangle pattern - alternate version
#include <iostream>
int main()
{
char ch;
int n,j,k;
std::cout<<" Enter a character : ";
std::cin>>ch;
std::cout<<" Ener the no of lines to print : ";
std::cin>>n;
for (int i=1; i<=n; i++)
{
for (j=n; j>=i; j--)
std::cout<<" "; // for blank spaces
for (k=1; k<=i; k++)
std::cout<<ch;
std::cout<<std::endl; // to leave a line space
}
std::cin.get(); // to see the output
return 0;
} // end of main
#include <iostream>
int main()
{
char ch;
int n,j,k;
std::cout<<" Enter a character : ";
std::cin>>ch;
std::cout<<" Ener the no of lines to print : ";
std::cin>>n;
for (int i=1; i<=n; i++)
{
for (j=n; j>=i; j--)
std::cout<<" "; // for blank spaces
for (k=1; k<=i; k++)
std::cout<<ch;
std::cout<<std::endl; // to leave a line space
}
std::cin.get(); // to see the output
return 0;
} // end of main
Star patten in alternate triangle |
0 comments:
Post a Comment
Comment Here....