+ 5

For loops

please, Is it possible to declare two variables in a for loop?........ e.g: for(int y = 3, d =5; y <= 10; d++)

1st Jul 2018, 7:03 PM
Roff Bilex
Roff Bilex - avatar
22 Réponses
+ 60
yes you can declare two variables with for loop like this for(int i=0, j=5; i < 5; i++, j--) but take care condition part is not separated by seperator (,) for(int i=0, j=5; i < 5, j > 5; i++, j--)
1st Jul 2018, 7:09 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 21
Yes, it is possible to instantiate two variables of the same type in the for loop declaration. But this example is an infinite loop, because you test the variable that isn't incremented. Just try it out at the code playground.
1st Jul 2018, 7:10 PM
Tashi N
Tashi N - avatar
+ 5
yes,it is possible
2nd Jul 2018, 2:50 PM
Amar Kumar
Amar Kumar - avatar
+ 5
Var x=0 For(;×<=20 x+=_) Document.write(×)
14th May 2020, 10:47 AM
Jatin
+ 4
Declaring multiple variables in a single declaration could cause confusion about the types of variables and their initial values. In particular, do not declare any of the following in a single declaration: - Variables of different types - A mixture of initialized and uninitialized variables In general, you should declare each variable on its own line with an explanatory comment regarding its role. While not required for conformance with this guideline, this practice is also recommended in the Code Conventions for the Java Programming Language, §6.1, “Number Per Line” [Conventions 2009].
5th Jul 2018, 11:49 AM
Oleksandr Chekalenko
Oleksandr Chekalenko - avatar
+ 3
yes
2nd Jul 2018, 12:36 PM
Rahman Rezaie 🇦🇫
Rahman Rezaie 🇦🇫 - avatar
+ 3
yes excatly
3rd Jul 2018, 8:01 AM
Elias Dayoub
Elias Dayoub - avatar
+ 3
what dose means sum =0
16th Apr 2020, 12:39 PM
Hashan Rajaguru
Hashan Rajaguru - avatar
+ 3
Can someone help me to fill this_blank
14th May 2020, 10:57 AM
Jatin
+ 2
yes you can and you can do another thing for example for(int i = 0 , j = n ; i < n ; --j , ++i) { }
10th Jul 2018, 8:52 AM
kais hasan
kais hasan - avatar
+ 2
Yes it is possible like we declared variables by separating them like int a=3, b=4;
20th Nov 2019, 5:22 AM
MukhlisA AbdurakhimovA
MukhlisA AbdurakhimovA - avatar
+ 1
yea you can
4th Jul 2018, 2:21 PM
Ephraim
Ephraim - avatar
+ 1
Of course
18th Feb 2020, 11:34 AM
R.Prakash
R.Prakash - avatar
+ 1
yes it is possible.
25th Feb 2020, 8:11 AM
Yash Panchal
Yash Panchal - avatar
+ 1
👌
19th Mar 2020, 5:25 AM
Makoye Ndalahwa
Makoye Ndalahwa - avatar
+ 1
It is possible. It can be done with more than 2 variables. You could use 10 variables if you wanted to.
9th Jul 2020, 1:24 PM
Steven Crowther
Steven Crowther - avatar
0
yes you can.
3rd Jul 2018, 2:28 AM
Raouf Yasin
Raouf Yasin - avatar
0
Yes it is possible
8th Mar 2020, 2:55 PM
BARUCH PRINCE
BARUCH PRINCE - avatar
0
Как мне это решить!!!!!??????? >:(
25th May 2020, 3:19 PM
Директор Компании GAME OVER STUDIO
Директор Компании GAME OVER STUDIO - avatar
0
Can someone plz explain this code to me in brief ??
3rd Sep 2020, 1:14 PM
√𝕄𝕋𝕃𝔼𝕆²⁸²²🥀
√𝕄𝕋𝕃𝔼𝕆²⁸²²🥀 - avatar