This program is using setw() and setfill() it supposed to output the stars I have included the sample output at the end of my project
I hope u gona be able to read the code cause my coding does not print the stars the way they have to be instead it prints 2 more stars in the middle and If u cud possible be able to detect the logic error please help I have included the code
#include "stdafx.h"
#include <iostream>
#include <iomanip>
using namespace std;
void main()
{
int space = 2;
int counter = 19;
int count = 1;
cout << "Assignment 1 --- Question 2.2" << endl;
cout << endl;
cout << setfill('*') << setw(23) << "*" << endl;
cout << setfill('*') << setw(23) << "*" << endl;
for(int x = 1; x <= 10; x++)
{
counter--;
cout << "**";
cout << setfill(' ') << setw(count);
cout << setw(count) << "*" << setfill(' ');
cout << setw(counter) << setfill(' ') << "*";
cout << setw(space) << setfill('*') << setfill(' ') << "**" << endl;
count++;
space++;
counter--;
}
for(int x = 1; x <= 10; x++)
{
space--;
count--;
counter++;
cout << "**";
cout << setfill(' ') << setw(count);
cout << setw(count) << "*" << setfill(' ');
cout << setw(counter) << setfill(' ') << "*";
cout << setw(space) << setfill('*') << setfill(' ') << "**" << endl;
counter++;
}
cout << setfill('*') << setw(23) << "*" << endl;
cout << setfill('*') << setw(23) << "*" << endl;
cout << endl;
}
//This is what I am suppose to produce but instead it produces two more stars in the middle
//sample output
**************
**************
*** ***
** * * **
** * * **
** * * **
** * **
** * * **
** * * **
** * * **
*** ***
**************
**************