9 Mar 2013

pattern_rectangle

/*
program to print following pattern

***********************
*                     *
*                     *
*                     *
*                     *
***********************

*/




#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,j,x,y,z;
cout<<"Enter rows:";
cin>>i;
cout<<"Enter cloumns:";
cin>>j;
for(x=1;x<=i;x++)
{
if((x==1)||(x==i))
{
for(y=1;y<=j;y++)
{
cout<<"*";
}
}
else
{
for(z=1;z<=j;z++)
{
if((z==1)||(z==j))
{
cout<<"*";
}
else
{
cout<<" ";
}
}
}
cout<<'\n';
}
getch();
}

Categories: ,

0 comments:

Post a Comment

Copyright © UPgradeCODING | Powered by Blogger