Guys any idea for this equivalent c loops in java:::
for (sum=0,i=0,j=0;i<10;i++,j+=2)
sum+=i+j
Thank you:
jamesPH
int sum=0, j=0;
for (int i =0; i<10; i++) {
j +=2;
sum += i+j;
}
(IMHO this is far clearer anyway)
Yes, that's much clearer, and the compressed style should be avoided.
However, the posted code should compile and run in Java. Was there some sort of question about it?
int sum=0, j=0;
for (int i =0; i<10; i++) {
j +=2;
sum += i+j;
}(IMHO this is far clearer anyway)
Thanks JamesCherrill....:D
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.