-
March 9th, 2009, 10:59 AM
#1
asterisk patterns
my code is working but I cannot make it function the right way, my program should display the following pattern, given the value of n and m. example if n=5, and m=6,
the output should be:
*****
*___*
*___*
*___*
*___*
*****
but my wrong code outputs this:
*****
*
*
*
*
*
*
*
*
*
*
*
*
******
please help me to correct my code,
this is my wrong code
#include <iostream.h>
#include <conio.h>
int main()
{
int m,n,o;
cout<<"entr #";
cin>>n;
cout<<"entr #";
cin>>m;
for (n=1;n<=m;++n)
{cout<<"*";
}
for (m=2;m<=n;++m)
{
cout<<"\n";
cout<<"*";
}
for (n=2;n<=m;++n)
{cout<<"\n";
cout<<"*";}
for (m=3;m<=n;++m)
{cout<<"*";
}
getch();
}
please help me, thanks in advance.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|