Copyright © Programs ++
Design by Dzignine
Wednesday 25 January 2012

Descending Triangle Pattern - alternate version

// Program to print a descending 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=0; j<i; j++)
            std::cout<<" "; // prints white spaces
        for (k=n; k>=i; k--)
            std::cout<<ch; // prints the specified character 
    
        std::cout<<std::endl; // to leave a line space
    }
    std::cin.get();
    return 0; // to display the output
} // end of main
Descending star pattern -alter nate

0 comments:

Post a Comment

Comment Here....