To output a * or any other character:
cout<<'*'<<endl;
notice the quotes around the character are single quotes. endl(endline) tells the compiler to start a new line.
endl : the character at the end is a small L, not a 1.
To output a * or any other character:
cout<<'*'<<endl;
notice the quotes around the character are single quotes. endl(endline) tells the compiler to start a new line.
endl : the character at the end is a small L, not a 1.
now u guys r talking $$$$ bout me
ok, got it. now how to make it add 1 each line.
Code:#include <iostream.h> int main() { int x=0; while(x<6) { cout <<'*'<< endl; x++; } return 0; }
1) Try not to reply twice in a row so much. Instead, edit your post.
2) None of us are talking $$$$ about you.
3) No offense but, In the words of bennyandthejets,Use the links I gave you to learn more about for loops and nested loops, which you'll need to make this star program. The whole point of making this program in the first place is so that you figure out how to create it. If we make it for you, that won't do you any good.we're not going to wipe your ass for you okay?
Last edited by funkydude9; 08-10-2003 at 10:24 PM.
Well, there are a few things wrong with your code:
1) It does not work.
2) It does not work.
3) It does not work.
Hope this helps.
everyone else can probably make something 10x better but I am lazy and hate console programming.Code:int main(int argc, char *argv[]) { short NumOfStars = 1; for(short i = 0; i<=6; i++) { for(short p = 0; p < NumOfStars;p++) { cout << "*"; } NumOfStars++; cout << endl; } return 0; }
ur lucky u can make that
unanimous' code can be made succincter by throwing away 'NumOfStars', and replacing 'p < NumOfStars' with 'p <= i'.
The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.
I compiled your code on my compiler and it didn't come out as the half treeOriginally posted by funkydude9
Tell ya what, why don't you take a closer look at nested loops You won't need to store '*' in any variable, just output it. Also, always use::EDIT::Code:int main()
This page has some neat tutorials/examples as well to help get you started.
*
**
***
****
*****
******
Instead it all came out in a single line.
I tried the program and being the newbie I am to c++, I made it long. Here is what I came up with.
If anyone knows of a shorter way of doing this please help out.Code:# include <iostream> using namespace std; int main() { int x; for (x = 0; x < 6; ++x) { if (x >=1) { cout <<"*"; } if (x >=2) { cout <<"*"; } if (x >=3) { cout <<"*"; } if (x >=4) { cout <<"*"; } if (x >=5) { cout <<"*"; } if (x >=2) { cout <<"*"; } cout <<"*" <<endl; } sytem("pause"); return 0; }
Knowledge is power and I want it all
-0RealityFusion0-
Yours is only called Quake 5 because you won't finish it before yr. 2010Originally posted by blackrat364
You'll have to beat me to Quake 4. Actually, mine's going to be so good, I'm calling it Quake 5.
:grins:
I did it using nesting loops, it was only like 10 lines of code. Just look up stuff on nesting loops to figure it out, there are tutorials everywhere. Good luck.
Brendan
Draco dormiens nunquam titallandus.
Console Graphics Library: http://www.geocities.com/steve_alberto/cgl.html
Like I said, anyone can make one 10x better than me. Its amazing how unoptimized a lot of my code is...just kill me now!!!Originally posted by Zach L.
unanimous' code can be made succincter by throwing away 'NumOfStars', and replacing 'p < NumOfStars' with 'p <= i'.
ummmm......if u read anything at all, i said i need to know how to add 1* each lineOriginally posted by RealityFusion
I compiled your code on my compiler and it didn't come out as the half tree
*
**
***
****
*****
******
Instead it all came out in a single line.
I tried the program and being the newbie I am to c++, I made it long. Here is what I came up with.
If anyone knows of a shorter way of doing this please help out.Code:# include <iostream> using namespace std; int main() { int x; for (x = 0; x < 6; ++x) { if (x >=1) { cout <<"*"; } if (x >=2) { cout <<"*"; } if (x >=3) { cout <<"*"; } if (x >=4) { cout <<"*"; } if (x >=5) { cout <<"*"; } if (x >=2) { cout <<"*"; } cout <<"*" <<endl; } sytem("pause"); return 0; }
and btw, u spelled system , sytem. and what does the statement system (pause); mean?
I think he meant to add a '\n' or endl somewhere in his cout statements to create a new line...system("pause") is os dependent but basically causes the program to wait for a keypress before continuing.
"Think not but that I know these things; or think
I know them not: not therefore am I short
Of knowing what I ought."
-John Milton, Paradise Regained (1671)
"Work hard and it might happen."
-XSquared
ok i got it now. now tell me a easy program to make. im pretty bored. i got dev-c++ open and waiting