What are the parameters needed to create a for loop?
Answers
Answered by
46
Basically, you need four parameters to create a for-loop-
1. Initialization
eg- int i=1;
2. Testing
eg- i<=10;
3. Updation
eg. i++;
4. Body-of-loop
System.out.println(i);
Combining all the above parts as per the syntax of the for loop, we have
for(int i=1; i<=10; i++){
System.out.println(i);
}
It should be noted that any of the above points(except 4th) are NOT mandatory, i.e., you can leave out one or all of the above three points, as in the following snippet-
for( ; ; )
System.out.println("Endless Loop");
Thank You:)
ashwin456ojha:
yes! you're right!
Answered by
5
Answer:
mark my answer as brainlest
Attachments:
Similar questions