This is a Cpp Program which prints out the diamond with stars pattern.
Download Code PROGRAM :
OUTPUT :
Diamond with stars ( pattern) |
#include <iostream> using namespace std; int main() { int i, j, k,n; cout << "Enter number of lines[height of diamond] : \t" ; cin >> n; for(i=1; i<=n; i++) { for(j=i; j<n; j++) { cout << " "; } for(k=1; k<(i*2); k++) { cout << "*"; } cout << "\n"; } for(i=n-1; i>=1; i--) { for(j=n; j>i; j--) { cout << " "; } for(k=1; k<(i*2); k++) { cout << "*"; } cout << "\n"; } return 0; }
OUTPUT :