Coding Help

Togepiover 10 years ago

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.

Poll
If you code, what language do you prefer?
Python31%19
C++21%13
Java16%10
Other8%5
Ruby6%4
Combo (the right answer)6%4
C# (lol)5%3
Javascript3%2
deleteddeletedover 10 years ago
Oksus
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.
Togepiover 10 years ago
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.
deleteddeletedover 10 years ago
Togepi
Idk who you are but hi!!
wtf im me
2
deleteddeletedover 10 years ago
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
deleteddeletedover 10 years ago
Because I have to declare x before I cin>> x; and I want to do it outside the loop
Togepiover 10 years ago
Idk who you are but hi!!
Perishover 10 years ago
i can help with codogings.

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

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


return 0;
}
Togepiover 10 years ago
Can you show me the code? Can't really give advice without seeing it.
deleteddeletedover 10 years agoedited
there is, but for some reason when I do it, the code doesnt work the way it should.
Only happens in a for loop
Togepiover 10 years ago
Sims
Togepi
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?
deleteddeletedover 10 years ago
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.
1
Whitepimp007over 10 years ago
This happened in my Python class today... WTF...

http://puu.sh/n5SpF/67dc0d4627.png
Simsover 10 years ago
Togepi
I don't write C++, but is cin >> user input?
yes
Togepiover 10 years ago
Holy crap has it really almost been 30 days? ._.
deleteddeletedover 10 years ago
People who are choosing python are probably casual as
Togepiover 10 years ago
I don't write C++, but is cin >> user input?
deleteddeletedover 10 years ago
Not home right now
deleteddeletedover 10 years ago
Uhh copy paste your code that isn't working
deleteddeletedover 10 years ago
Togepi
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.