Trying to get an outcome that looks like this..
#
?#
??#
?#
#

What I'm getting is this...
#
?#
?#?#

compiles ok, but as you can see it places the # after each ? rather than grouping them together, and it neglects to count back down.
Don't want to have my homework done for me, just want an idea where to look for the trouble. head spinning.

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])

{
char bend = '#';//#@ beginning and end
char cues = '?';
int n,x,y ;
cout <<"Please enter number of ?'s :";
cin >> n;
cout<< bend<< endl;
for(y=1;y<=n;y++)
{
for(x=1;x<=y;x++)
{
cout<< cues <<bend;
}
cout<< endl;
}
for(y=1;y>=n;y--)
{
for(x=1;x>=y;x--)
{
cout<< cues << bend;
}
cout<< bend << endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}


any help would be greatly appreciated

Welcome to Daniweb. Before anyone can help you please read this Read this before posting.

Following the tips here will make it easy for people to understand your problem, read your code, provide a better solution and will help you make the most of Daniweb.

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
  char bend = '#';//#@ beginning and end 
  char cues = '?';
  int n,x,y ; 
  cout <<"Please enter number of ?'s :";
  cin >> n;
  cout<< bend<< endl; 
  for(y=1;y<=n;y++) { 
    for(x=1;x<=y;x++) { 
      cout<< cues <<bend; 
    } 
    cout<< endl; 
  } 
  for(y=1;y>=n;y--) { 
    for(x=1;x>=y;x--) { 
      cout<< cues << bend;
    } 
    cout<< bend << endl; 
  } 
  system("PAUSE");
  return EXIT_SUCCESS;
}

Let's start with your actual output. You're getting "?#?#..." because that's what you're telling it to do. Do you see the problem with these statements:

char bend = '#';//#@ beginning and end 
char cues = '?';
for (int i = 0; i < 5; ++i) {
  cout<< cues <<bend;
}
cout << endl;

??? You need to put your "bend" in a different, later, statement.

Here's your second set of loops:

for(y=1;y>=n;y--) { 
    for(x=1;x>=y;x--) { 
      cout<< cues << bend;
    } 
    cout<< bend << endl; 
  }

This is essentially the correct thing to do to reverse the taper, but you didn't create your starting and control conditions correctly. As currently written, the control condition on your outer loop starts out false so it never runs. You are correct in thinking they should decrement, but you are starting with a "low"/false value instead of with a valid "high" value.

Edited 5 Years Ago by Fbody: n/a

Thanks for the help here's what I ended up with after fiddling around with it for an hour, putting things in different places, and changing values.

for(y=n;y>=0;y--)
{
for(x=y-1;x>=1;x--)
{
cout<< cues;
}
cout<< bend << endl;

Here's what it looks like now:
#
?#
??#
???#
??#
?#
#
#
Got an extra # at the end. I work on it in class today.
Thank You for the direction.

This question has already been answered. Start a new discussion instead.