Difference between revisions of "Java/C2/For-Loop/English"
Arya Ratish (Talk | contribs) |
Arya Ratish (Talk | contribs) |
||
Line 39: | Line 39: | ||
'''Prerequisites''' | '''Prerequisites''' | ||
− | | style="border:1pt solid #000000;padding:0.097cm;"| For this tutorial, you should have knowledge on '''relational operators | + | | style="border:1pt solid #000000;padding:0.097cm;"| For this tutorial, you should have knowledge on '''relational operators ''' and '''if statement''' in Java. |
Revision as of 18:24, 23 January 2013
Title of script: for loop in Java
Author: TalentSprint
Keywords: conditions, loops, for loop, video tutorial
Visual Cue | Description |
Slide 1
Welcome |
Welcome to the spoken tutorial on for loop. |
Slide 2
Learning Outcomes |
In this tutorial, you will learn how to use the for loop in Java. |
Slide 3
Tools Used |
For this tutorial we are using
|
Slide 4
Prerequisites |
For this tutorial, you should have knowledge on relational operators and if statement in Java.
|
Slide 5
Syntax |
Here is the syntax of the for loop.
|
Minimize Slides and open Eclipse
Eclipse should contain the following code public class ForLoopDemo{ public static void main(String[] args){ } } |
We have the skeleton required.
|
Inside the main function, type
int i; for (i = 0; i < 10; i = i + 1)
|
Inside the main function, type int i semicolon.
|
Highlight i = 0 | This is the starting condition for the loop.
|
Highlight i < 10 | This is the loop running condition.
|
Highlight i = i + 1 | This states how the loop variable is going to change.
|
Change for (i = 0; i < 10; i = i + 1) to for (i = 0; i < 10; i = i + 1) {
System.out.println( i * i ); }
|
Now, open and close curly brackets.
|
Save and run. Point to output | As we can see, the loop ran over numbers from 0 to 9.
|
Change i = 0 to i = 10 | So, i should have values from 10 to 99.
|
Change i < 10 to i < 100 | Change i less than 10 to i less than 100. |
Change System.out.println( i * i ) to
if ((i % 3 == 0) || (i % 5 == 0)){ System.out.println(i); } |
Delete System dot out dot println within brackets i into i.
if within brackets i mod 3 double equal to 0 or i mod 5 double equal to 0.
|
Save and run. Highlight the output | We can see that the numbers are either multiples of 3 or of 5. |
Minimize the Eclipse window and switch to slides.
Summary |
We have come to the end of this tutorial.
In this tutorial we have learnt how to use for loop in java. |
Slide 7Assignment | A three digit number is called Armstrong Number if it is equal to the sum of cubes of its digits.
|
Slide 8About the Spoken Tutorial Project
|
To know more about the Spoken Tutorial project, watch the video available at the following link, that summarises the project.Alternatively, you can download and watch it. |
Slide 9Spoken Tutorial WorkshopsThe Spoken Tutorial Project Team
|
The Spoken Tutorial Project Team. Conducts workshops using spoken tutorials and gives certificates for those who pass an online test. For more details, please write to contact AT spoken HYPHEN tutorial DOT org. |
Slide 10Acknowledgement
|
Spoken Tutorial Project is a part of the Talk to a Teacher project and is supported by the National Mission on Education through ICT, MHRD, Government of India. More information on this Mission is available at spoken HYPHEN tutorial DOT org SLASH NMEICT HYPHEN Intro |
Slide 11About the contributor
|
This script has been contributed by TalentSprint.
This is Prathamesh Salunke signing off. Thanks for joining.
|