Can someone please o please tell me a program to make? I am very bored. But make it sorta easy. I started learning about a week ago. I know cout, cin, int, char, and other small doodads I think. Thanks!
Printable View
Can someone please o please tell me a program to make? I am very bored. But make it sorta easy. I started learning about a week ago. I know cout, cin, int, char, and other small doodads I think. Thanks!
How about playing around with a new concept: arrays?
int my_array[3];//creates 3 int variables, with index values 0, 1, 2
my_array[0]=10;
my_array[1]=20;
my_array[2]=30;
cout<<my_array[0]<<endl;
cout<<my_array[1]<<endl;
cout<<my_array[2]<<endl;
Mmm...arrays. How about making a 3D game like Quake? ;)
Do you have mad loop skillz? Try outputting this:
Code:*
**
***
****
*****
Lol, i am working on quake4. lol. those progs look cool, arrays i think r too advanced, and i dont know loops. well, a lil lil if....else.
You'll have to beat me to Quake 4. Actually, mine's going to be so good, I'm calling it Quake 5.Quote:
Originally posted by oobootsy1
Lol, i am working on quake4. lol. those progs look cool, arrays i think r too advanced, and i dont know loops. well, a lil lil if....else.
Anyway, loops are really easy to learn, and arrays aren't too difficult. Check out the tutorials on this site.
You could also make a very basic text-adventure with a couple rooms.
Just knowing a little I/O won't get you very far. Loops are really cool and fun (did I mention fun?). Check out these tutorials
if and else aren't loops, loops are while, do while, and for.
Play with those, check out the tutorials for more help.Code:for (int i = 0; i < 10; ++i)
{
cout << i << "\n";
}
while (v1 != v2)
{
++v1;
}
do
{
++v1;
}
while (v1 != v2);
Quote:
Originally posted by funkydude9
Just knowing a little I/O won't get you very far. Loops are really cool and fun (did I mention fun?). Check out these tutorials
whats I/O? ok, ima look at tuts on loops. and what did u mean by making a text adventure with "rooms"?
Input & output
well i did make this yesterday. kinda cool.........
Code:#include <iostream.h>
void main()
{
int age;
char name;
int weight;
char hair;
{
cout << "Welcome! I will need some information about you!";
cout << "\nPlease enter your first letter of your name: ";
cin >> name;
cout << "\nPlease enter your age: ";
cin >> age;
cout << "\nPlease enter your weight: ";
cin >> weight;
cout << "\nFinally, Please enter your first letter of your hair color: ";
cin >> hair;
cout << "\nOK! Your freakin name starts with a: " << name << "!";
cout << "\nYou are " << age << " years old!";
cout << "\nYou weigh " << weight << " pounds!";
cout << "\nAnd the first letter of your ugly hair color is: " << hair << "!";
cout << "\n Thanks! Have a nice day!";
cout << "\n..........I wish char can hold more letters.....*sigh*";
}
}
and whats the difference between int and void? the faq was too confusing
int returns an integer to main(), void returns nothing to main() (or whoever called the function).Quote:
and whats the difference between int and void? the faq was too confusing
Or did you mean int main() or void main()?
I'm sure these people will tell you, never, EVER use void main(), only int main(). :)
well, lemme try that
*
**
***
thing some1 said in a loop. i well probably be back in a minute saying i cant make it, too hard. well, here i go.........
You'll need to use nested loops. (a loop inside of a loop).Quote:
well, lemme try that
*
**
***
thing some1 said in a loop. i well probably be back in a minute saying i cant make it, too hard. well, here i go.........
i new it. i thought i could do it. but i dunno how to make *'s. only numbers. anyways, it errors.
Code:#include <iostream.h>
void main()
{
int x=0
while(x<6)
{
cout << x << endl;
x++;
}
}
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.
WOOHOO!! i debugged by myself and got it.-
but now, how to i make them stars? the * thingsCode:#include <iostream.h>
int main()
{
int x=0;
while(x<6)
{
cout << x << endl;
x++;
}
return 0;
}
Quote:
Originally 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 useCode:int main()
ok, lemme try that tut. looks cool. brb
seems like ill have to ask the user to make the character *. i cant find out how to make it output that without asking the user.
EDIT-im am complete shutdown/ im so confused. on how to hav the *
I recommend that you try and learn more C++. That is quite a project in itself! ^_^
Quote:
Originally posted by Zoalord
I recommend that you try and learn more C++. That is quite a project in itself! ^_^
like??
;)Code:cout << '*';
Reply after you have read and understood the first couple of tutorials on this site, and if you still don't understand what your're reading check out the site that I posted in my last post. That should give you a good start.Quote:
like??
Quote:
Originally posted by funkydude9
Reply after you have read and understood the first couple of tutorials on this site, and if you still don't understand what your're reading check out the site that I posted in my last post. That should give you a good start.
uh oh. people r getting annoyed. see, im stupid. i should just go and kill myself. i always make others mad because i cant do anything without some1's help. i should just end my life...........make people like funkydude9 happier........:(
naaah... Just try to make more of an effort before asking. Buy a book maybe? And do not post a new book thread or you will get flamed :). Use the search!Quote:
Originally posted by oobootsy1
uh oh. people r getting annoyed. see, im stupid. i should just go and kill myself. i always make others mad because i cant do anything without some1's help. i should just end my life...........make people like funkydude9 happier........:(
i got a book. but it is kinda big and kinda confusing in parts. instead of showing like the while loop in a small program, it shows it in a 10page program.
There are plenty of good books out there and even some free ones. (type c++ in the search on that page). The tutorials on this site are very short and to the point; you should really read them over carefully, and experiment with them. They're a good place to start. :)
Also, Google is your friend. :)
Time for a new book then. Do a search. You'll find plenty about books here. A good idea would be just to go to a book store, and look through the various books for a while, to find one that suits your learning style.
Cheers
What book do you have?Quote:
Originally posted by oobootsy1
i got a book. but it is kinda big and kinda confusing in parts.
He must have: "The Big C++ Book" by Jo Confused :DQuote:
What book do you have?
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.Quote:
we're not going to wipe your ass for you okay?
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'.
I compiled your code on my compiler and it didn't come out as the half treeQuote:
Originally 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;
}
Yours is only called Quake 5 because you won't finish it before yr. 2010 :)Quote:
Originally 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
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!!! :DQuote:
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 lineQuote:
Originally 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.
ok i got it now. now tell me a easy program to make. im pretty bored. i got dev-c++ open and waiting
I'm ahead of you darksaidin :pQuote:
Originally posted by darksaidin
Yours is only called Quake 5 because you won't finish it before yr. 2010 :)
:grins:
(and just so you know, I'm completely joking around with you. I think it's great that you're trying 3d stuff)
edit: How easy? tic-tac-toe is easy, but it might be beyond you - I haven't read this thread very closely. Have you ever played any of the Zork games? (they're text adventures) Try programming the very beginning of one of those - you could even use their descriptions if you wanted.
it comes with time. don't worry, you'll get better at it.Quote:
Originally posted by oobootsy1
ur lucky u can make that
as for something to program, what about try the contest forum and look at the beginner stuff. it's good practice, and if you don't know something, you'll learn it.
they have har stuf. i need sumthin simple.
Get a new book. Read it. Everytime you learn something new, make a program using that. Rinse and repeat. In Approx 6-8months you will have a solid grasp of C++. :). Seriously though, go read tutorials! Until you at least learn functions and structs C++ is boring :).
edit: Is it so hard to type out SOMETHING etc...
Of course! It would be two extra letteQuote:
Originally posted by o0obruceleeo0o
good advice...
edit: Is it so hard to type out SOMETHING etc...