I can make a box with a char quite easily where the user enters two values L, and W using a for loop
but I don't know how to make just the outline. I'm told there are 2 if else statements needed and I've nested my for loop. I don't know how to restrict in the if statement so it will loop char going across, then empty spaces followed by char, then last line gets printed, any help would be appreciated

for (int myHeight =1;myHeight < width; myHeight++)
{
for (int myBase=1;myBase<length;myBase++)
{
cout <<c;
}
}

So you want to do something like this?

eeeeeeeeeeeeeeeee
e               e
e               e
e               e
eeeeeeeeeeeeeeeee

but don't know how? Or you want this?

eeeeeee
e  e  e
e  e  e
eeeeeee

but it ends up like this?

eeeeeee
eee
eee
eeeeeee

Can you elaborate please? I'm not sure what you are trying to do.

use:

for (int myHeight =1;myHeight <width; myHeight++)
	{
		for (int myBase=1;myBase<length;myBase++)
		{
			if(myBase==1 || myBase==length-1 )
				printf(c);
			else if(myHeight==1 || myHeight==width-1)
				printf(c);
			else
				printf(" ");
		}
		printf("\n");
	}
commented: Help the write their own program! They learn nothing if you write it for them! -2

vernon
it's the top box, the numbers are off int myBase =1, and myHeight=1

I get too many spaces

Did you try to incorporate any of DangerDev's code? Some of the lines using "printf" had problems, but when fixed, yielded a box that lined up for me. You could either change the "printf" statements to make them work or simply convert the "printf" statements to "cout" statements.

You say you "get too many spaces". In your original code that you posted I don't see you displaying any spaces at all. I am assuming that in this line:

cout << c;

c represents a character and that c is not a space. Please let us know whether you have gotten this working and, if not, please post some updated code.

It is very big mistake to write

printf(c);

Correct is

printf("%c", c);

.
Remember the definition:

printf(argument, ...);
for (int myHeight =0; myHeight< width-2; myHeight++) 
        {
            cout << c;

        }

        for (int myHeight =0; myHeight< myHeight; myHeight++)    
        {
            for (int myBase =0; myBase< width-2; myBase++)   
            {
                cout << c;

                cout << (" ");
            }

            cout << c;


        }  

        for (int myHeight =0; myHeight< width; myHeight++)   
        {
            cout << c;

            cout << endl;
        }

return 0;

}

this is what gives me only two sides of the box, I need a whole box

for (int myHeight =0; myHeight< myHeight; myHeight++)

Look at this line. This loop will never be executed due to the condition you have imposed:

myHeight < myHeight
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.