Welcome to Gaia! ::

Reply
c++ help

Quick Reply

Enter both words below, separated by a space:

Can't read the text? Click here

Submit

jayco121

PostPosted: Wed May 31, 2006 2:27 pm


im trying to write a c++ app that goes from 1-10
unfortunatly im used to c so how do i do this is c++
PostPosted: Wed May 31, 2006 11:05 pm


ok so what do you mean do you want it to display the numbers from one to ten? explain it better please. i could probably help if i had better info like if you just need it to display 10 numbers or if a person puts a number then something happens. something like that would probably help better.

dark_rocket


Moonbat

PostPosted: Wed Nov 15, 2006 5:40 pm


Just use a FOR loop, like this (not sure if syntax is correct or not)

for (i=0;i<10;i++)
{
int numbah=i;
cout << numbah;
}
PostPosted: Sat Dec 02, 2006 8:27 am


C++ has prety much the same concepts as C so all you do is compile the C version in a C++ compiler, all them will compile C.

the syntax is a little diferent, not as many ( ) as you would like but you can get used to it after a while.

the code in the post above should be:
for (int i=0;i<10;i++)
{
int numbah=i;
cout << numbah;
}

*hence the INT*
dont want a nasty error there do we?

EDIT woah dude moonbat! your here too? lol

Dooms_Day704

Newbie Noob

200 Points
  • Member 100
  • Gaian 50

Paulymer

PostPosted: Wed Dec 13, 2006 11:01 pm


Why use a "numbah" at all?

int i;
for (i = 0; i < 10; i++) {
cout << i << endl;
}
PostPosted: Tue Jan 30, 2007 7:50 pm


can anyone remind me how to dynamically allocate an array?

goodguy5


CCubed

PostPosted: Mon May 26, 2008 10:50 pm


Paulymer
Why use a "numbah" at all?

int i;
for (i = 0; i < 10; i++) {
cout << i << endl;
}


Why use int i? Also, this code will only do 1-9, not 1-10.


for (i(0)I<11;I++){
cout << i << endl;
}


Yeah for resurrecting threads! I just had to point out the faulty logic though.
PostPosted: Sat Dec 06, 2008 8:25 pm


int i;
for (i = 0; i < 10; i++) {
cout << i << endl;
}


Actually this code prints 0 to 9.


for (i(0)I<11;I++){
cout << i << endl;
}


And this would print 0 to 10, after a few errors are fixed.

Skyte Aero


a2toedmonkey

PostPosted: Sun Dec 14, 2008 11:24 am


Wouldn't it be easier to just say the following?



for(int i=0;i<=10;i++){
cout<}


I beleive this would go to 10.
Reply


 
Manage Your Items
Other Stuff
Get GCash
Offers
Get Items
More Items
Where Everyone Hangs Out
Other Community Areas
Virtual Spaces
Fun Stuff
Gaia's Games
Mini-Games
Play with GCash
Play with Platinum