Difference between revisions of "Java/C2/For-Loop/English-timed"
From Script | Spoken-Tutorial
(Created page with ' {| border=1 || ''Time''' || '''Narration''' |- | 00:02 | Welcome to the spoken tutorial on '''for loop''' in java. |- | 00:07 | In this tutorial, you will learn how…') |
PoojaMoolya (Talk | contribs) |
||
(6 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | + | {| border=1 | |
− | + | || '''Time''' | |
− | + | ||
− | + | ||
− | + | ||
− | {| border=1 | + | |
− | || ''Time''' | + | |
|| '''Narration''' | || '''Narration''' | ||
|- | |- | ||
| 00:02 | | 00:02 | ||
− | | Welcome to the spoken tutorial on '''for loop''' in | + | | Welcome to the spoken tutorial on '''for loop''' in java. |
|- | |- | ||
| 00:07 | | 00:07 | ||
− | | In this tutorial, you will learn how to use the '''for loop | + | | In this tutorial, you will learn how to use the '''for loop''' in Java. |
|- | |- | ||
| 00:12 | | 00:12 | ||
− | | For this tutorial we are using | + | | For this tutorial, we are using: |
− | + | '''Ubuntu 11.10''' | |
− | + | '''JDK 1.6''' and | |
− | + | '''Eclipse 3.7.0''' | |
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
| 00:24 | | 00:24 | ||
− | | For this tutorial, you should have knowledge | + | | For this tutorial, you should have knowledge of '''relational operators''' and '''if statement''' in Java. |
− | + | ||
|- | |- | ||
| 00:32 | | 00:32 | ||
− | |If not, for relevant | + | |If not, for relevant tutorials, please visit our website which is as shown. [http://spoken-tuitorial.org] |
|- | |- | ||
Line 39: | Line 30: | ||
|- | |- | ||
| 00:44 | | 00:44 | ||
− | |It | + | |It consists of '''initialization''', '''loop condition''' and '''increment'''. |
|- | |- | ||
| 00:51 | | 00:51 | ||
− | |Then it has the for block which keeps on executing till the loop condition is true. | + | |Then it has the '''for block''' which keeps on executing till the '''loop condition''' is true. |
|- | |- | ||
Line 50: | Line 41: | ||
|- | |- | ||
| 01:04 | | 01:04 | ||
− | | So switch to '''eclipse''' | + | | So, switch to '''eclipse'''. |
|- | |- | ||
| 01:07 | | 01:07 | ||
|We already have a '''class''' named '''ForLoopDemo'''. | |We already have a '''class''' named '''ForLoopDemo'''. | ||
− | |||
|- | |- | ||
Line 62: | Line 52: | ||
|- | |- | ||
| 01:17 | | 01:17 | ||
− | | So | + | | So, inside the '''main method''' , type: '''int i''' semicolon. |
− | + | ||
|- | |- | ||
| 01:24 | | 01:24 | ||
− | |Then | + | |Then, '''for''' within parentheses '''i ''' equal to '''0''' semicolon '''i ''' less than '''10''' semicolon '''i ''' equal to '''i''' plus '''1'''. |
− | + | ||
|- | |- | ||
| 01:45 | | 01:45 | ||
− | |This statement decides how the loop is going to progress. | + | |This statement decides how the '''loop''' is going to progress. |
|- | |- | ||
| 01:53 | | 01:53 | ||
− | | i =0 is the starting condition for the loop. | + | | i =0 is the starting condition for the '''loop'''. |
− | + | ||
|- | |- | ||
Line 84: | Line 71: | ||
|- | |- | ||
| 02:05 | | 02:05 | ||
− | | | + | | i<10 is the '''loop running condition'''. |
− | + | ||
|- | |- | ||
| 02:09 | | 02:09 | ||
− | |If the condition is true then the for block will be executed. | + | |If the condition is true then the '''for block''' will be executed. |
− | + | ||
|- | |- | ||
| 02:14 | | 02:14 | ||
− | |Else it will be ignored. | + | |Else, it will be ignored. |
− | + | ||
|- | |- | ||
| 02:17 | | 02:17 | ||
− | |That means when i becomes more than or equal to 10, the block is not executed. | + | |That means, when 'i' becomes more than or equal to 10, the '''block''' is not executed. |
|- | |- | ||
| 02:25 | | 02:25 | ||
− | | Then i= i+1 | + | | Then i= i+1 states how the '''loop variable''' is going to change. |
− | + | ||
|- | |- | ||
| 02:32 | | 02:32 | ||
− | |Here, the value of i starts with 0. | + | |Here, the value of 'i' starts with 0. |
− | + | ||
|- | |- | ||
| 02:35 | | 02:35 | ||
− | |It keeps increasing by 1 for every iteration of the loop until it becomes 10. | + | |It keeps increasing by 1, for every iteration of the loop, until it becomes 10. |
− | + | ||
|- | |- | ||
| 02:42 | | 02:42 | ||
− | |Now let us do something with i. | + | |Now, let us do something with 'i'. |
|- | |- | ||
| 02:46 | | 02:46 | ||
| So open and close curly brackets. | | So open and close curly brackets. | ||
− | |||
|- | |- | ||
| 02:49 | | 02:49 | ||
− | | Inside the curly brackets type '''System | + | | Inside the curly brackets, type: '''System''' dot '''out''' dot '''println''' and print '''i''' into '''i'''. |
− | + | ||
|- | |- | ||
| 03:06 | | 03:06 | ||
|This will print the square of each number from 0 to 9. | |This will print the square of each number from 0 to 9. | ||
− | |||
|- | |- | ||
| 03:11 | | 03:11 | ||
|Let us see the output. | |Let us see the output. | ||
− | |||
|- | |- | ||
| 03:13 | | 03:13 | ||
− | |So '''save''' and '''run''' the program | + | |So '''save''' and '''run''' the program. |
|- | |- | ||
| 03:17 | | 03:17 | ||
| As we can see, the loop run over numbers from 0 to 9. | | As we can see, the loop run over numbers from 0 to 9. | ||
− | |||
|- | |- | ||
| 03:23 | | 03:23 | ||
|The square of the number has been printed in each iteration. | |The square of the number has been printed in each iteration. | ||
− | |||
|- | |- | ||
| 03:28 | | 03:28 | ||
− | |Now let us print all the 2 digit numbers that are multiples of 3 or 5. | + | |Now, let us print all the 2 digit numbers that are multiples of 3 or 5. |
|- | |- | ||
| 03:37 | | 03:37 | ||
− | | So, '''i '''should have values from 10 to 99. | + | | So, '''i''' should have values from 10 to 99. |
− | + | ||
|- | |- | ||
| 03:42 | | 03:42 | ||
− | |So change''' i | + | |So, change '''i''' equal to '''0''' to '''i''' equal to '''10'''. |
|- | |- | ||
| 03:48 | | 03:48 | ||
− | | And '''i | + | | And '''i''' less than '''10''' to '''i ''' less than '''100'''. |
|- | |- | ||
| 03:54 | | 03:54 | ||
− | | Then inside the curly brackets | + | | Then, inside the curly brackets, we print the number only if it is a multiple of 3 or 5. |
− | + | ||
|- | |- | ||
| 04:03 | | 04:03 | ||
− | |So type | + | |So type:'''if''' within brackets '''i''' mod '''3''' equal equal to '''0''' OR within brackets '''i''' mod '''5 ''' equal equal to '''0''' |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
| 04:32 | | 04:32 | ||
− | |This statement checks whether | + | |This statement checks whether 'i' is divisible by '3'or by '5'. |
− | + | ||
|- | |- | ||
| 04:38 | | 04:38 | ||
− | |Then, in curly | + | |Then, in curly brackets, we will print the value of 'i'. |
|- | |- | ||
Line 199: | Line 166: | ||
|- | |- | ||
| 04:52 | | 04:52 | ||
− | |So save and run the program | + | |So '''save''' and '''run''' the program. |
− | + | ||
− | + | ||
|- | |- | ||
| 04:56 | | 04:56 | ||
− | | We can see that the numbers are either multiples of 3 or | + | | We can see that the numbers are either multiples of 3 or 5. In this way we use '''for loop''' in Java. |
|- | |- | ||
Line 213: | Line 178: | ||
|- | |- | ||
| 05:14 | | 05:14 | ||
− | |In this tutorial we have | + | |In this tutorial we have learned how to use '''for loop''' in java. |
|- | |- | ||
| 05:20 | | 05:20 | ||
− | | For assignment , a three digit number is called Armstrong Number if it is equal to the sum of cubes of its digits. | + | | For assignment, a three digit number is called Armstrong Number if it is equal to the sum of cubes of its digits. |
− | + | ||
|- | |- | ||
| 05:29 | | 05:29 | ||
− | |For example, 153 is equal to 1 cube plus 5 cube plus 3 cube. | + | |For example, 153 is equal to '1 cube' plus '5 cube' plus '3 cube'. |
− | + | ||
|- | |- | ||
Line 231: | Line 194: | ||
|- | |- | ||
| 05:40 | | 05:40 | ||
− | | To know more about the | + | | To know more about the Spoken Tutorial project, |
|- | |- | ||
− | | 05: 42 | + | | 05:42 |
− | |watch the video available at the spoken-tuitorial.org/ | + | |watch the video available at the spoken-tuitorial.org/What_is_a_Spoken-Tuitorial? |
|- | |- | ||
| 05:49 | | 05:49 | ||
− | | | + | |It summarizes the Spoken Tutorial project. If you do not have good bandwidth, you can download and watch it. |
|- | |- | ||
| 05:56 | | 05:56 | ||
− | | | + | | The Spoken Tutorial project team: Conducts workshops using spoken tutorials, |
|- | |- | ||
| 06:01 | | 06:01 | ||
− | | gives certificates | + | | gives certificates to those who pass an online test. |
|- | |- | ||
| 06:04 | | 06:04 | ||
− | |For more details, please write to '''contact | + | |For more details, please write to '''contact@spoken Hyphen tutorial dot org.''' |
|- | |- | ||
| 06:10 | | 06:10 | ||
− | | | + | | 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. |
|- | |- | ||
| 06:20 | | 06:20 | ||
− | | | + | | More information on this mission is available at '''spoken hyphen tutorial dot org Slash NMEICT hyphen Intro'''. |
|- | |- | ||
| 06:28 | | 06:28 | ||
− | | This script has been contributed by '''TalentSprint'''. | + | | This script has been contributed by '''TalentSprint'''. This is Prathamesh Salunke, signing off.Thanks for joining. |
− | + | ||
− | Thanks for joining. | + | |
− | + | ||
− | + | ||
− | + | ||
|} | |} |
Latest revision as of 19:26, 20 February 2017
Time | Narration |
00:02 | Welcome to the spoken tutorial on for loop in java. |
00:07 | In this tutorial, you will learn how to use the for loop in Java. |
00:12 | For this tutorial, we are using:
Ubuntu 11.10 JDK 1.6 and Eclipse 3.7.0 |
00:24 | For this tutorial, you should have knowledge of relational operators and if statement in Java. |
00:32 | If not, for relevant tutorials, please visit our website which is as shown. [1] |
00:40 | Here is the syntax of the for loop. |
00:44 | It consists of initialization, loop condition and increment. |
00:51 | Then it has the for block which keeps on executing till the loop condition is true. |
01:00 | Now, let us try out an example in Eclipse. |
01:04 | So, switch to eclipse. |
01:07 | We already have a class named ForLoopDemo. |
01:12 | Let us add the for loop inside the main method. |
01:17 | So, inside the main method , type: int i semicolon. |
01:24 | Then, for within parentheses i equal to 0 semicolon i less than 10 semicolon i equal to i plus 1. |
01:45 | This statement decides how the loop is going to progress. |
01:53 | i =0 is the starting condition for the loop. |
01:58 | This condition allows the variable to be initialized. |
02:05 | i<10 is the loop running condition. |
02:09 | If the condition is true then the for block will be executed. |
02:14 | Else, it will be ignored. |
02:17 | That means, when 'i' becomes more than or equal to 10, the block is not executed. |
02:25 | Then i= i+1 states how the loop variable is going to change. |
02:32 | Here, the value of 'i' starts with 0. |
02:35 | It keeps increasing by 1, for every iteration of the loop, until it becomes 10. |
02:42 | Now, let us do something with 'i'. |
02:46 | So open and close curly brackets. |
02:49 | Inside the curly brackets, type: System dot out dot println and print i into i. |
03:06 | This will print the square of each number from 0 to 9. |
03:11 | Let us see the output. |
03:13 | So save and run the program. |
03:17 | As we can see, the loop run over numbers from 0 to 9. |
03:23 | The square of the number has been printed in each iteration. |
03:28 | Now, let us print all the 2 digit numbers that are multiples of 3 or 5. |
03:37 | So, i should have values from 10 to 99. |
03:42 | So, change i equal to 0 to i equal to 10. |
03:48 | And i less than 10 to i less than 100. |
03:54 | Then, inside the curly brackets, we print the number only if it is a multiple of 3 or 5. |
04:03 | So type:if within brackets i mod 3 equal equal to 0 OR within brackets i mod 5 equal equal to 0 |
04:32 | This statement checks whether 'i' is divisible by '3'or by '5'. |
04:38 | Then, in curly brackets, we will print the value of 'i'. |
04:50 | Now, let us see the output. |
04:52 | So save and run the program. |
04:56 | We can see that the numbers are either multiples of 3 or 5. In this way we use for loop in Java. |
05:11 | We have come to the end of this tutorial. |
05:14 | In this tutorial we have learned how to use for loop in java. |
05:20 | For assignment, a three digit number is called Armstrong Number if it is equal to the sum of cubes of its digits. |
05:29 | For example, 153 is equal to '1 cube' plus '5 cube' plus '3 cube'. |
05:36 | Find all such 3 digit numbers. |
05:40 | To know more about the Spoken Tutorial project, |
05:42 | watch the video available at the spoken-tuitorial.org/What_is_a_Spoken-Tuitorial? |
05:49 | It summarizes the Spoken Tutorial project. If you do not have good bandwidth, you can download and watch it. |
05:56 | The Spoken Tutorial project team: Conducts workshops using spoken tutorials, |
06:01 | gives certificates to those who pass an online test. |
06:04 | For more details, please write to contact@spoken Hyphen tutorial dot org. |
06:10 | 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. |
06:20 | More information on this mission is available at spoken hyphen tutorial dot org Slash NMEICT hyphen Intro. |
06:28 | This script has been contributed by TalentSprint. This is Prathamesh Salunke, signing off.Thanks for joining. |