I have to make a program for generating the following output:
Example:
& & & & & & &
& & & & &
& & &
&
What I have done so far:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,j,k,n;
cout<<"How many rows?\n";
cin>>n;
for(i=n;i>0;i-=2)
{
cout<<"\n";
for(k=(i+1)/2;k>0;--k)
cout<<" ";
for(j=1;j<=i;++j)
cout<<"&";
}
}
What the output comes:
& & & & &
& & &
&
Please correct me where I am making the mistake. Any help will be appreciated. Thanks.