C++ Program – Array in Given Pattern

by Nideesh C on May 2, 2011 · 0 comments

in C++




//Downloaded From theonlinetutorials.com
//(C)2011.All rights reserved.

/*
4 3 2 1
0 3 2 1
0 0 2 1
0 0 0 1
*/

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,n,g,j,a[100],b[100][100];
cout<<"Enter Limit"<<endl;
cin>>n;
cout<<"Enter "<<endl;
for(g=0;g<n;g++)
cin>>a[g];

for(i=0;i<n;i++)
{
for(j=n-1;j>=0;j--)
{
b[i][j]=a[j];
}
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(i>j)
b[i][j]=0;
}
}
for(i=0;i<n;i++)
{
cout<<endl;
for(j=0;j<n;j++)
{
cout<<b[i][j]<<" ";
}
}

getch();
}



Not Satisfied ? Just search & get the result

Related Posts Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. C++ Program – Insert & Delete an element from array
  2. Sample – Program to enter 10 integers in a single-dimension array and then print out the array in ascending order.
  3. C++ Program – Display diamond and pascals triangle
  4. C++ Program – Simple & Compound Interest
  5. C++ Program – Array Based Representation of Linear List using templates

Leave a Comment

Previous post:

Next post: