446,194 Members | 859 Online
Need help? Post your question and get tips & solutions from a community of 446,194 IT Pros & Developers. It's quick & easy.

 P: n/a I am writing a program that tells users to enter 2 sides of a rectangle. From that the program will output a drwaing of the rectangle using "*"'s... Here is my problem. Say I enter 5 and 10 for the 2 sides.. This is what is output. ********** * * * * * * * ********** I dont know why it is adding that asterk on the first row.. Same thing happens if I enter 2 other sides. Etc... Any help would be appriciated!!! Here is my code so far: I use Turbo hence the .h #include #include #include int main() { clrscr(); int side1, side2; cout<<"Please enter side 1: "; cin>>side1; cout<<"Please enter side 2: "; cin>>side2; for(int a=1; a
12 Replies

 P: n/a "1111111111" wrote in message news:3f**************************@posting.google.c om... I am writing a program that tells users to enter 2 sides of a rectangle. From that the program will output a drwaing of the rectangle using "*"'s... Here is my problem. Say I enter 5 and 10 for the 2 sides.. This is what is output. ********** * * * * * * * ********** I dont know why it is adding that asterk on the first row.. Same thing happens if I enter 2 other sides. Etc... Any help would be appriciated!!! Here is my code so far: I use Turbo hence the .h #include #include #include int main() { clrscr(); int side1, side2; cout<<"Please enter side 1: "; cin>>side1; cout<<"Please enter side 2: "; cin>>side2; for(int a=1; a

 P: n/a "1111111111" wrote in message news:3f**************************@posting.google.c om... I am writing a program that tells users to enter 2 sides of a rectangle. From that the program will output a drwaing of the rectangle using "*"'s... Here is my problem. Say I enter 5 and 10 for the 2 sides.. This is what is output. ********** * * * * * * * ********** I dont know why it is adding that asterk on the first row.. Same thing happens if I enter 2 other sides. Etc... Any help would be appriciated!!! Because you are forgetting to output a newline after the end of the first row (and after the end of the last row). The extra asterisk is actually the second asterisk on the next row. There are some other problems but you'll probably figure out those once you've fixed this one. There's a lesson here, computer do exactly what you tell them to, not what you *think* you've told them to. john Jul 22 '05 #3

 P: n/a On 18 May 2004 11:58:28 -0700, eh***@hotmail.com (1111111111) wrote: I am writing a program that tells users to enter 2 sides of arectangle. From that the program will output a drwaing of therectangle using "*"'s... Here is my problem. Say I enter 5 and 10 forthe 2 sides.. This is what is output.********** ** ** ** ***********I dont know why it is adding that asterk on the first row.. Samething happens if I enter 2 other sides. Etc... Any help would beappriciated!!!Here is my code so far: I use Turbo hence the .h#include #include #include int main(){clrscr();int side1, side2;cout<<"Please enter side 1: ";cin>>side1;cout<<"Please enter side 2: ";cin>>side2;for(int a=1; a

 P: n/a 1111111111 wrote: for(int a=1; a

 P: n/a * eh***@hotmail.com (1111111111) schriebt: Here is my code so far: I use Turbo hence the .h Get yourself a C++ compiler, e.g. mingw g++ (it's free). #include #include #include Fix the above when you've got yourself a C++ compiler. int main() { clrscr(); int side1, side2; cout<<"Please enter side 1: "; cin>>side1; cout<<"Please enter side 2: "; cin>>side2; for(int a=1; a

 P: n/a "Alf P. Steinbach" wrote in message news:40****************@news.individual.net... * eh***@hotmail.com (1111111111) schriebt: Here is my code so far: I use Turbo hence the .h Get yourself a C++ compiler, e.g. mingw g++ (it's free). #include #include #include Fix the above when you've got yourself a C++ compiler. I take it you mean a "conforming" C++ compiler? VC++ 6.0 certainly uses a C++ compiler, but it's not conforming in this aspect (and others, no doubt). (It's one of several I have, and am required to use due to compatibility with SDKs for some of the audio programs I write. One cannot always choose the compiler at will.) int main() { clrscr(); int side1, side2; cout<<"Please enter side 1: "; cin>>side1; cout<<"Please enter side 2: "; cin>>side2; for(int a=1; a

 P: n/a I take it you mean a "conforming" C++ compiler? VC++ 6.0 certainly uses a C++ compiler, but it's not conforming in this aspect (and others, no doubt). Oops...I mixed up my response a little after rearranging it. The "this aspect" part I was referring to above was the following: 5) (2) and (3), plus: you don't have to introduce a new loop control variable name (when using a C++ compiler, that is). In VC++ 6.0 you have to either enclose the code in braces or define the loop variable just once, because it does not correctly scope the loop control variable. -Howard Jul 22 '05 #8

 P: n/a Alf P. Steinbach wrote: * eh***@hotmail.com (1111111111) schriebt: Here is my code so far: I use Turbo hence the .h Get yourself a C++ compiler, e.g. mingw g++ (it's free). No, do not use that one. A much better free one is availible from Microsoft here: http://msdn.microsoft.com/visualc/vctoolkit2003/ - Pete Jul 22 '05 #9

 P: n/a 1111111111 wrote: I am writing a program that tells users to enter 2 sides of a rectangle. From that the program will output a drwaing of the rectangle using "*"'s... Here is my problem. Say I enter 5 and 10 for the 2 sides.. This is what is output. ********** * * * * * * * ********** I dont know why it is adding that asterk on the first row.. You are. You didn't put any kind of end of line termination following the first line of '*' characters. Here's a fixed up version. I changed your loops to start from 0 and use consistent comparisons. Also your use of endl was overkill, so I changed it to be a line terminator. int main() { int side1, side2; cout<<"Please enter side 1: "; cin>>side1; cout<<"Please enter side 2: "; cin>>side2; for(int a=0; a

 P: n/a 1111111111 wrote: I am writing a program that tells users to enter 2 sides of a rectangle. From that the program will output a drwaing of the rectangle using "*"'s... Here is my problem. Say I enter 5 and 10 for the 2 sides.. This is what is output. Oh, I meant to add, learn to use your debugger. Follow through the program execution. Brian Rodenborn Jul 22 '05 #11

 P: n/a The problem is that you're not moving to the next line after the first row of *s. If you write: ********* Then: * * The result is ********** * Just add a "cout << endl;" after the first for and replace "a... I am writing a program that tells users to enter 2 sides of a rectangle. From that the program will output a drwaing of the rectangle using "*"'s... Here is my problem. Say I enter 5 and 10 for the 2 sides.. This is what is output. ********** * * * * * * * ********** I dont know why it is adding that asterk on the first row.. Same thing happens if I enter 2 other sides. Etc... Any help would be appriciated!!! Here is my code so far: I use Turbo hence the .h #include #include #include int main() { clrscr(); int side1, side2; cout<<"Please enter side 1: "; cin>>side1; cout<<"Please enter side 2: "; cin>>side2; for(int a=1; a

 P: n/a > > Get yourself a C++ compiler, e.g. mingw g++ (it's free). No, do not use that one. A much better free one is availible from Microsoft here: http://msdn.microsoft.com/visualc/vctoolkit2003/ This oughta be rich........................ ;-) Jul 22 '05 #13

### This discussion thread is closed

Replies have been disabled for this discussion.