How to use for loop | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to use for loop

24th Jul 2016, 10:41 AM
Amit Chouhan
Amit Chouhan - avatar
6 Answers
0
here instead of i you can use any variable , and instead of N you can put any limit up to which the loop will continue and instead of i++ we can use i-- . all depends on your requirements
24th Jul 2016, 11:03 AM
Dhiman Das
Dhiman Das - avatar
0
int i; for(i=0;i<n;i++) { //execute ur code//}
24th Jul 2016, 5:48 PM
Rohit Sarkar
Rohit Sarkar - avatar
0
for(int i=0; i<=n;i++) { /* your code*/ }
25th Jul 2016, 5:09 AM
mahi
0
Instead of i++ you can also use other statements like i*2 or i+I if you want
25th Jul 2016, 10:04 PM
ein siedler
ein siedler - avatar
0
you can also use foreach
27th Jul 2016, 2:52 PM
Sanjeev Kumar Bharti
Sanjeev Kumar Bharti - avatar
- 3
for( i = 0, i < N, i++)
24th Jul 2016, 11:01 AM
Dhiman Das
Dhiman Das - avatar