Thursday, December 18, 2014

Spaceless triangular sterric pattern

//c++ program to display pattern like that

//user only enter the size
#include <iostream>
using namespace std;
int main()
{
 int size,temp_variable;  //declaring variables
 cout<<"Enter size = ";  //asking for output
 cin>>size;     //input
 temp_variable=size;   //storing sizze in temporary variable
 if(size>0)
 {
  for(int i=1;i<=size;i++)   //outer loop controlling number of rows
  {
   for(int j=1;j<=temp_variable;j++)  //inner loop controlling number of columns
   {
    cout<<"*";
   }
   temp_variable--;   //applying decrement
   cout<<endl;
  }
 }
 else
 {
  cout<<"PLease enter size greater than zero.\n";
 }
 return 0;
}

No comments:

Post a Comment