Sunday, 5 May 2013

Series


1) * * * * * *                         1 1 1 1 1 1
    * * * * *                            1 1 1 1 1
    * * * *                               1 1 1 1
    * * *                                  1 1 1
    * *                                     1 1
    *                                        1



Assume n is number of * or 1 in first row


PROGRAM                                              OUTPUT
#include <iostream>
using namespace std;
int main ()
{
  int i,n,j;
  cout << "Input Value of n:";
  cin>>n; 
  for(i=n;i>0;i--)
  {
    for(j=0;j<i;j++) 
      /*Print 1 or * or as per ur requriment */
      cout<<"*"<<"\t"; 
    }       
    cout<<endl;   //new line
}
 return 0;
}
Input Value of n:3
 
* * *
* *
* 

No comments:

Post a Comment