over 8 years

I'm going to post here when I can't figure out certain aspects of Java. I don't know how many of you know the language well, but help will be appreciated as I go through this bootcamp.

Also an excuse for me to post a countdown until Doomsday.

If you code, what language do you prefer?
19
Python
13
C++
10
Java
5
Other
4
Ruby
4
Combo (the right answer)
3
C# (lol)
2
Javascript
deletedover 8 years

Oksus says

int main()
{
int x;
cin >> x;

for (x > 20; x++)
{
cout << x;
}



return 0;
}
and if i dont decalre it in the loop, like this, the code wont run at all.
This is why i need help xD


can't you do for(x=x; x>20; x++)

you should note that if x is greater than 20, then you have an infinite loop.
over 8 years
You have to declare the variable type before you assign it? In Java it would be int x = System.in or whatever, but I don't see how it would run because I would think the compiler would break at int x since it's not doing anything but declaring the type rather than assigning a value.
deletedover 8 years

Togepi says

Idk who you are but hi!!


wtf im me
deletedover 8 years
int main()
{
int x;
cin >> x;

for (x > 20; x++)
{
cout << x;
}



return 0;
}
and if i dont decalre it in the loop, like this, the code wont run at all.
This is why i need help xD
deletedover 8 years
Because I have to declare x before I cin>> x; and I want to do it outside the loop
over 8 years
Idk who you are but hi!!
over 8 years
i can help with codogings.

semicolons. ;;;;;;;;
over 8 years
hi
over 8 years
Ayyyyeeeee
over 8 years
toge
over 8 years
hi
over 8 years
Why are you declaring x twice? You're instantiating it once outside of the loop and then again in the scope of the loop.
deletedover 8 years
int main()
{
int x;
cin >> x;

for (int x; x > 20; x++)
{
cout << x;
}


return 0;
}
over 8 years
Can you show me the code? Can't really give advice without seeing it.
deletedover 8 years
there is, but for some reason when I do it, the code doesnt work the way it should.
Only happens in a for loop
over 8 years

Sims says


Togepi says

I don't write C++, but is cin >> user input?


yes


Is there no way to assign the input to a variable and call it in the loop with that?
deletedover 8 years
Still loving Ruby & Rails. Pounding away at Rails like a sailor who just got back to shore after six months pounds at a hooker's diseased snatch.
over 8 years
This happened in my Python class today... WTF...

http://puu.sh/n5SpF/67dc0d4627.png
over 8 years

Togepi says

I don't write C++, but is cin >> user input?


yes
over 8 years
Holy crap has it really almost been 30 days? ._.
deletedover 8 years
People who are choosing python are probably casual as
over 8 years
I don't write C++, but is cin >> user input?
deletedover 8 years
Not home right now
deletedover 8 years
Uhh copy paste your code that isn't working
deletedover 8 years

Togepi says

I am a loop master.


Mind explaining the For loop to me in c++.
I have this problem where i cannot get it to work unless i specify the value before.
If I want to input the value using cin >>, for some reason it won't register properly in the for loop.