I am unable to run for loop, please help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I am unable to run for loop, please help

For loop

9th May 2020, 8:17 PM
Nilesh Chawla
Nilesh Chawla - avatar
26 Answers
+ 6
python: for i in range(start, end, increment): statement-block for eg, for I in range(1,10,2): print(i, end="") Ruby: for I in (1...10) puts i end c++: for(assign, condition, increment){ statement-block } for eg, for(i=1;i<=10;i++){ cout<< i << end; } Java: for(int i=1;i<=10;i++){ system.println.out(i); } C: for(int i=0, i<10, i++) printf("%i", i); which language for loop do you ask? Explain the question clearly?
11th May 2020, 3:14 PM
Jenson Y
+ 5
remove semicolon after for(i=1;i<=10;i++)
9th May 2020, 8:19 PM
andriy kan
andriy kan - avatar
+ 3
You mustn't set a semicolon after for
9th May 2020, 8:25 PM
Jason
Jason - avatar
+ 2
es6 in 4th item in the above list pertains to java👆
10th May 2020, 5:19 AM
narayanaprasad
narayanaprasad - avatar
10th May 2020, 5:21 AM
narayanaprasad
narayanaprasad - avatar
10th May 2020, 5:22 AM
narayanaprasad
narayanaprasad - avatar
+ 2
for(i=1;i<=10;i++) the last vale 10 will be incremented to 11
10th May 2020, 1:55 PM
Asrar
Asrar - avatar
+ 2
Recheck ur program By removing the semicolon after the statement
11th May 2020, 5:57 AM
ɴɪᴛʜʏᴀɴᴀɴᴅᴀ
ɴɪᴛʜʏᴀɴᴀɴᴅᴀ - avatar
+ 1
Please remove the semicolon after your first line of loop because when you set the semicolon There you separate the loop and the cod in Im sorry my english is Awful
9th May 2020, 8:29 PM
Jason
Jason - avatar
+ 1
I think its good to add "\n" after i in your print function to go to next line after print
9th May 2020, 8:35 PM
Jason
Jason - avatar
10th May 2020, 3:46 AM
narayanaprasad
narayanaprasad - avatar
+ 1
Thats how the for loop is= For( i =0 ; i<= 10 ; i++ ) No semicolon at end .......
10th May 2020, 2:03 PM
Naveed
Naveed - avatar
10th May 2020, 4:40 PM
Nilesh Chawla
Nilesh Chawla - avatar
+ 1
My pleasure.Nilesh Chawla
10th May 2020, 5:01 PM
Naveed
Naveed - avatar
0
public class Program { public static void main(String[] args) { int i; for(i=1;i<=10;i++); { System.out.print("Value is " + i); } } }
9th May 2020, 8:17 PM
Nilesh Chawla
Nilesh Chawla - avatar
0
I am getting value as 11
9th May 2020, 8:17 PM
Nilesh Chawla
Nilesh Chawla - avatar
0
But I require series of value from 1 to 10 one by one
9th May 2020, 8:18 PM
Nilesh Chawla
Nilesh Chawla - avatar
0
Please help
9th May 2020, 8:18 PM
Nilesh Chawla
Nilesh Chawla - avatar
9th May 2020, 8:19 PM
Nilesh Chawla
Nilesh Chawla - avatar
0
Thanks a lot, how a ; make a difference here?
9th May 2020, 8:21 PM
Nilesh Chawla
Nilesh Chawla - avatar