I need to write a simple C++ program using DEV-C++. I need to write a program th
ID: 3638308 • Letter: I
Question
I need to write a simple C++ program using DEV-C++.
I need to write a program that displays the following diamond pattern:
*
***
*****
*******
*****
***
*
Explanation / Answer
please rate - thanks
#include<iostream>
using namespace std;
int main()
{int i,j,k,n=7;
for(j=1;j<=n;j+=2)
{for(i=1;i<=(n-j)/2;i++)
cout<<" ";
for(k=1;k<=j;k++)
cout<<"*";
cout<<endl;
}
for(j=n-1;j>=2;j-=2) //1 less line on bottom
{for(i=1;i<=(n-j+1)/2;i++)
cout<<" ";
for(k=1;k<j;k++)
cout<<"*";
cout<<endl;
}
system("pause");
return 0;
}