Difference between revisions of "C-and-C++/C3/Working-With-2D-Arrays/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
 
(9 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{| border=1
+
{| border = 1
|| ''Time'''
+
|'''Time'''
|| '''Narration'''
+
|'''Narration'''
  
 
|-
 
|-
| 00:02
+
| 00:01
| Welcome to the spoken-tutorial on '''2dimensional Arrays''' in '''C''' and '''C++.'''
+
|Welcome to the spoken-tutorial on '''2 Dimensional Arrays''' in '''C''' and '''C++.'''
  
 
|-
 
|-
|00:08
+
| 00:08
| In this tutorial we will learn,
+
|In this tutorial, we will learn
  
 
|-
 
|-
| 00:11
+
| 00:10
| What is a 2dimensional '''array.'''
+
|what is a '''2 Dimensional array.'''
  
 
|-
 
|-
 
| 00:13
 
| 00:13
| We will do this through an example.
+
|We will do this through an example.  
  
 
|-
 
|-
| 00:16
+
| 00:16
| To record this tutorial, I am using
+
|To record this tutorial, I am using  
  
 
|-
 
|-
|00:19
+
| 00:18
| '''Ubuntu Operating System''' version 11.10,
+
| '''Ubuntu Operating System''' version 11.10,  
  
 
|-
 
|-
| 00:23
+
| 00:22
| '''gcc''' and '''g++''' '''Compiler''' version 4.6.1 on Ubuntu
+
|'''gcc''' and '''g++ Compiler''' version 4.6.1 on Ubuntu.
  
 
|-
 
|-
| 00:30
+
| 00:29
| Let us start with the introduction to '''2 dimensional Array'''
+
| Let us start with the introduction to '''2 dimensional Array'''.
  
 
|-
 
|-
| 00:34
+
| 00:33
| '''2-D arrays are stored in a row column matrix.'''
+
|'''2D arrays''' are stored in a row column matrix.
  
 
|-
 
|-
| 00:38
+
|00:38
| '''The left index indicates the row.'''
+
| The left index indicates the row.
  
 
|-
 
|-
| 00:42
+
|00:41
| '''The right index indicates the column.''' '
+
|The right index indicates the column.  
  
 
+
|-
 
+
|00:44
 +
|Starting index of a matrix or array in C and C++ is always 0.
  
 
|-
 
|-
| 00:45
+
|00:52
|'''Starting index of a matrix or array in C and C++ is always 0.'''
+
|Here, we see a 2 Dimensional array in a row column matrix.  
  
 
|-
 
|-
| 00:52
+
| 00:58
| Here we  see  a '''2 dimensional array'''
+
|Starting index is 0.
  
 
|-
 
|-
| 00:55
+
|01:01
| In a row column matrix. Starting index is'''0'''
+
|Now, let us see how to declare '''2 dimensional array'''.
 
+
  
 
|-
 
|-
| 01:01
+
| 01:04
| Now let us see how to declare a 2dimensional '''array'''
+
|The Syntax for this is:
  
|-
 
| 01:05
 
| The Syntax for this is:
 
 
|-
 
|-
 
| 01:07
 
| 01:07
| ''' data-type arr_name[row] [col]; '''
+
|'''data-type ,array name, row and column.'''
  
 
|-
 
|-
| 01:13
+
|01:13
| eg.'''  Here we have declare a 2 dimensional array   num[2][3]; '''
+
|example, here we have declared a 2 dimensional array '''num''' with 2 rows and 3 columns.
  
 
|-
 
|-
| 01:22
+
| 01:21
|Now let us see an example
+
|Now let us see an example.
 +
 
 
|-
 
|-
| 01:24
+
| 01:23
| I have already typed the program
+
|I have already typed the program, let me open it.
 +
 
 
|-
 
|-
| 01:26
+
|01:28
|Let me  open it.
+
|Note that our file name is '''2d hyphen array dot c'''.
 
+
  
 +
|-
 +
|01:33
 +
|In this program, we will calculate the sum of the elements of the 2 dimensional array.
  
 
|-
 
|-
| 01:28
+
|01:41
| Note that our file name is '''2d-array.c'''
+
|Let me explain the code now.
  
 
|-
 
|-
| 01:34
+
|01:44
|In this program we will calculate, the sum of the elements of the 2dimensional arrays.
+
|This is our '''header file.'''
  
 
|-
 
|-
| 01:41
+
|01:46
| Let me explain the code now.
+
|This is our '''main()''' function.
|-
+
|  01:44
+
| This is our '''header file.'''
+
  
 
|-
 
|-
| 01:47
+
|01:49
| This is our '''main function'''.
+
|Here we have declared variables i and j.  
  
 
|-
 
|-
|   01:49
+
| 01:53
| Here, we have declared variable '''i''' and '''j'''.
+
|Then we have declared num1 with 3 rows and 4 columns.  
  
 
|-
 
|-
| 01:53
+
| 01:58
|Then we have declared num1 with 3rows and 4columns
+
|And num2, again with 3 rows and 4 columns.
  
 
|-
 
|-
| 01:59
+
| 02:03
| And num2  again with 3rows and 4columns
+
|num1 and num2 are 2 dimensional arrays.
  
 
|-
 
|  02:04
 
| ''' num1''' and '''num2''' are 2dimensional arrays
 
 
|-
 
|-
| 02:08
+
| 02:07
|   Here we take elements of the matrix '''num1''' as input from the user.
+
|Here, we take elements of the matrix '''num1''' as input from the user.  
  
 
|-
 
|-
| 02:14
+
|02:13
| The elements are stored row-wise.
+
|The elements are stored row-wise.  
  
 
|-
 
|-
| 02:17
+
|02:16
| We have considered''' i''' for rows and ''' j '''for columns.
+
|We have considered i for rows and j for columns.
  
 
|-
 
|-
| 02:23
+
|02:22
| This for loop will check the condition that '''i''' runs from 0 to 2.
+
|This '''for''' loop will check the condition that i runs from 0 to 2.  
  
 
|-
 
|-
 
| 02:28
 
| 02:28
| This for loop will check the condition that''' j''' runs from 0 to 3.
+
|This '''for''' loop will check the condition that j runs from 0 to 3.  
  
 
|-
 
|-
| 02:34
+
| 02:33
|Similarly, here we take elements of the matrix '''num2''' as input from the user.
+
| Similarly, here we take elements of the matrix '''num2''' as input from the user.  
 
+
 
+
 
+
  
 
|-
 
|-
|   02:41
+
| 02:40
| Here we display the matrix '''num1'''
+
| Here we display the matrix num1.
  
 
|-
 
|-
| 02:44
+
| 02:43
|   Here''' %3d''' is used to align the matrix on the terminal.
+
| Here percent 3d is used to align the matrix on the terminal.
|-
+
|  02:50
+
|  Now here we display the matrix '''num2 '''
+
  
 
|-
 
|-
| 02:53
+
| 02:49
| Then we add the '''num1''' matrix and the '''num2 '''matrix
+
| Now, here we display the matrix num2.
  
 
|-
 
|-
| 02:57
+
|02:52
| And  display the result
+
|Then we add the num1 matrix and the num2 matrix and display the result.
  
 
|-
 
|-
| 03:00
+
| 02:59
| This is our return statement.
+
| This is our '''return''' statement.  
  
 
|-
 
|-
| 03:02
+
| 03:01
| Now, click on '''Save.'''
+
|Now, click on Save.
  
 
|-
 
|-
 
| 03:05
 
| 03:05
|   Let us execute the program.
+
| Let us execute the program.  
  
 
|-
 
|-
| 03:08
+
| 03:07
| Please open the terminal window by pressing '''Ctrl, Alt''' and '''T''' keys simultaneously on your keyboard.
+
|Please open the terminal window by pressing '''Ctrl, Alt''' and '''T''' keys simultaneously on your keyboard.  
  
 
|-
 
|-
| 03:15
+
| 03:15
| To compile type,
+
| To compile, type '''gcc''' space '''2d''' hyphen '''array''' dot '''c''' space '''hyphen o''' space''' arr''' and press '''Enter.'''
  
 
|-
 
|-
| 03:17
+
| 03:28
| '''gcc 2d-array.c -o arr''' and press '''enter'''
+
|To execute, type '''dot slash arr''' (./arr), now press '''Enter '''.
  
 
|-
 
|-
| 03:29
+
| 03:34
| To execute type, ./ arr now press '''enter'''.
+
|Here we see '''Enter the elements of 3 into 4 array num1'''.
  
 
|-
 
|-
| 03:34
+
| 03:39
| Here we see enter the element of''' 3 into 4 array num1'''.
+
| I will enter the values now.
 +
 
 
|-
 
|-
| 03:40
+
| 03:52
|I will enter the values now
+
| Now we can see '''Enter the elements of 3 into 4 array num2'''.
 +
 
 
|-
 
|-
| 03:52
+
| 03:57
|Now we can see enter the element of''' 3 into 4 array num2'''
+
|I will enter the values.
  
 
|-
 
|-
| 03:58
+
| 04:10
| I will enter the  values.
+
| The output is displayed.
|-
+
| 04:11
+
|The output is displayed,
+
  
 
|-
 
|-
 
| 04:13
 
| 04:13
|Here we can see the '''num1''' matrix.
+
|Here we can see the num1 matrix.
 +
 
|-
 
|-
| 04:17
+
| 04:16
|here we can see the '''num2''' matrix.
+
|Here we can see the num2 matrix.
 +
 
 
|-
 
|-
 
| 04:20
 
| 04:20
|And this is the sum of '''num1''' and '''num2'''
+
|And this is the sum of num1 and num2.
 +
 
|-
 
|-
 
| 04:24
 
| 04:24
| Now we will see how to execute the same program in C++.
+
|Now we will see how to execute the same program in C++.
 +
 
 
|-
 
|-
| 04:30
+
| 04:29
| I have already named the program. I will open it and explain.
+
|I have already made the program. I will open it and explain.
  
 
|-
 
|-
| 04:34
+
| 04:34
|This is the program for 2dimensional arrays in C++.
+
|This is the program for '''2 Dimensional arrays''' in C++.
 +
 
 
|-
 
|-
| 04:39
+
| 04:38
|Note that our file name is ''2d-array.cpp'''. The extension is '''.cpp'''.
+
| Note that our file name is''' 2d hyphen array dot cpp'''.
 +
 
 
|-
 
|-
| 04:48
+
| 04:43
|   Let me explain the code now. This is our '''header file''' as '''iostream'''
+
|The extension is '''dot cpp''' (.cpp).
+
 
 
|-
 
|-
| 04:53
+
| 04:47
| This is our '''using''' statement.
+
|Let me explain the code now.
 +
 
 
|-
 
|-
|04:56
+
| 04:50
|This is our '''main function'''
+
|This is our header file as '''iostream'''.
  
 +
|-
 +
| 04:53
 +
|This is our '''using''' statement.
  
 
|-
 
|-
|04:58
+
| 04:56
|Here we have '''cout'''function. As we use '''cout''' to print the output in C++.
+
|This is our '''main()''' function.
|-
+
|05:06
+
| Then we have '''cin'' function, we use '''cin'''  to read a line in C++
+
  
 
|-
 
|-
|05:14
+
| 04:58
|Here we use '''\t''' it means horizontal tab that is equivalent to 4 spaces.
+
|Here we have '''cout''' function as we use '''cout''' to print the output in C++.
 +
 
 
|-
 
|-
|  05:21
+
| 05:06
|  Rest of the code is similar to our '''c ''code .Now click on '''Save'''
+
|Then we have '''cin''' function. We use '''cin''' to read a line in C++.
+
 
 +
|-
 +
| 05:13
 +
|Here, we use '''/ t ''' bit mean horizontal tab that is equivalent to 4 spaces.
 +
 
 +
|-
 +
| 05:21
 +
|Rest of the code is similar to our C code.
 +
 
 +
|-
 +
| 05:25
 +
|Now click on Save.
 +
 
 
|-
 
|-
 
| 05:27
 
| 05:27
| Let us execute
+
|Let us execute. Come back to a terminal.
  
 
|-
 
|-
| 05:29
+
| 05:31
| Come back to our terminal
+
|Let me clear the prompt.
  
 
|-
 
|-
| 05:31
+
| 05:33
| Let me clear the prompt.
+
|To compile, type '''g++ space 2d hyphen array dot cpp  hyphen o space arr1''' and press ''' Enter.'''
 +
 
 
|-
 
|-
| 05:34
+
| 05:47
| To compile type, g++ 2d- array.cpp -o arr and press enter.
+
|To execute, type '''dot slash arr1''', now press Enter.
  
 
|-
 
|-
| 05:47
+
| 05:52
| To execute type,  ./arr1. Now press enter.
+
|Here we see '''Enter the elements of 3 into 4 array num1.'''
 +
 
 
|-
 
|-
| 05:53
+
| 05:57
| Here we see enter the element of 3 into 4 array num1.
+
|I will enter the values.
 +
 
 
|-
 
|-
| 05:58
+
| 06:07
| I will enter the values.
+
|Now, we see '''Enter the elements of 3 into 4 array num2.'''
 +
 
 
|-
 
|-
| 06:08
+
| 06:13
| Now we see enter the elements of 3 into 4 array num2.
+
|I will give the values as:
  
 
|-
 
|-
| 06:14
+
| 06:24
|I will give the values as
+
|The output is displayed.
 +
 
 
|-
 
|-
| 06:24
+
| 06:26
| The output is displayed  , We can see the '''num1 matrx''', '''num2 matrix'''.
+
|We can see the num1 matrix, the num2 matrix.
  
 
|-
 
|-
|06:32
+
| 06:31
| And this is the sum of num1 and num2.
+
|And this is the sum of num1 and num2.
 +
 
 
|-
 
|-
|06:36
+
| 06:36
 
|This brings us to the end of this tutorial.
 
|This brings us to the end of this tutorial.
 +
 
|-
 
|-
 
| 06:39
 
| 06:39
|Come back to our slides. Let us summarises
+
|Come back to our slide. Let us Summarize.
  
 
|-
 
|-
| 06:43
+
| 06:43
| In this tutprial we learnt,
+
|In this tutorial we learnt:
  
 
|-
 
|-
| 06:45
+
| 06:45
| To add elements in a 2D array.
+
|To add elements in a 2D array.  
  
 
|-
 
|-
| 06:49
+
| 06:48
| To print 2D array.
+
|To print 2D array.  
  
 
|-
 
|-
| 06:51
+
| 06:50
| And To calculate the sum of 2D array.
+
|And to calculate the sum of 2Dimensional array.  
 +
 
 
|-
 
|-
| 06:55
+
| 06:54
| As an assignment,
+
|As an assignment: Write the  program that takes two 2Dimensional arrays as input from the user.
  
 
|-
 
|-
| 06:56
+
| 07:01
| Write a program that takes two 2D arrays as input from the user.
+
|Subtract them and find the result.  
  
 
|-
 
|-
| 07:02
+
| 07:05
| Subtract them and find the result.
+
|Watch the video available at the link shown below:
  
 
|-
 
|-
| 07:05
+
| 07:08
| Watch the video available at the  link shown below 
+
|It summarizes the Spoken Tutorial project.
  
 
|-
 
|-
| 07:08
+
| 07:11
| It summarises the Spoken Tutorial project
+
|If you do not have good bandwidth, you can download and watch it.
  
 
|-
 
|-
| 07:11
+
| 07:15
| If you do not have good bandwidth, you can download and watch it
+
|The Spoken Tutorial Project Team:
  
 +
|-
 +
| 07:17
 +
|Conducts workshops using spoken tutorials.
  
 +
|-
 +
| 07:21
 +
|Gives certificates to those who pass an online test.
  
 
|-
 
|-
| 07:16
+
| 07:25
| The Spoken Tutorial Project Team
+
|For more details, please write to, contact@spoken-tutorial.org.
 +
 
 
|-
 
|-
| 07:18
+
|07:32
| Conducts workshops using spoken tutorials
+
|Spoken Tutorial Project is a part of Talk to a Teacher project.
  
 
|-
 
|-
| 07:21
+
| 07:36
| Gives certificates for those who pass an online test
+
|It is supported by the National Mission on Education through ICT, MHRD, Government of India.
  
 
|-
 
|-
|07:26
+
| 07:43
| For more details, please write to contact at spoken hyphen tutorial dot org
+
|More information on this mission is available at the link shown below.
 
+
 
+
  
 
|-
 
|-
| 07:33 
+
| 07:48
|   Spoken Tutorial Project is a part of the Talk to a Teacher project
+
|The script is contributed by Ritwik Joshi. This is Ashwini Patil from IIT Bombay.  
|-
+
|  07:37
+
| It is supported by the National Mission on Education through ICT, MHRD, Government of India 
+
|-
+
|  07:44
+
|More information on this Mission is available at  the link shown below.
+
+
 
+
  
 
|-
 
|-
| 07:49
+
| 07:54
|   The script is contributed  by  Ritwik Joshi  , this is Ashwini Patil from IIT Bombay.
+
|Thank you for watching.
 
+
Thank you for watching  
+
 
+
|}
+

Latest revision as of 14:29, 24 March 2017

Time Narration
00:01 Welcome to the spoken-tutorial on 2 Dimensional Arrays in C and C++.
00:08 In this tutorial, we will learn-
00:10 what is a 2 Dimensional array.
00:13 We will do this through an example.
00:16 To record this tutorial, I am using
00:18 Ubuntu Operating System version 11.10,
00:22 gcc and g++ Compiler version 4.6.1 on Ubuntu.
00:29 Let us start with the introduction to 2 dimensional Array.
00:33 2D arrays are stored in a row column matrix.
00:38 The left index indicates the row.
00:41 The right index indicates the column.
00:44 Starting index of a matrix or array in C and C++ is always 0.
00:52 Here, we see a 2 Dimensional array in a row column matrix.
00:58 Starting index is 0.
01:01 Now, let us see how to declare 2 dimensional array.
01:04 The Syntax for this is:
01:07 data-type ,array name, row and column.
01:13 example, here we have declared a 2 dimensional array num with 2 rows and 3 columns.
01:21 Now let us see an example.
01:23 I have already typed the program, let me open it.
01:28 Note that our file name is 2d hyphen array dot c.
01:33 In this program, we will calculate the sum of the elements of the 2 dimensional array.
01:41 Let me explain the code now.
01:44 This is our header file.
01:46 This is our main() function.
01:49 Here we have declared variables i and j.
01:53 Then we have declared num1 with 3 rows and 4 columns.
01:58 And num2, again with 3 rows and 4 columns.
02:03 num1 and num2 are 2 dimensional arrays.
02:07 Here, we take elements of the matrix num1 as input from the user.
02:13 The elements are stored row-wise.
02:16 We have considered i for rows and j for columns.
02:22 This for loop will check the condition that i runs from 0 to 2.
02:28 This for loop will check the condition that j runs from 0 to 3.
02:33 Similarly, here we take elements of the matrix num2 as input from the user.
02:40 Here we display the matrix num1.
02:43 Here percent 3d is used to align the matrix on the terminal.
02:49 Now, here we display the matrix num2.
02:52 Then we add the num1 matrix and the num2 matrix and display the result.
02:59 This is our return statement.
03:01 Now, click on Save.
03:05 Let us execute the program.
03:07 Please open the terminal window by pressing Ctrl, Alt and T keys simultaneously on your keyboard.
03:15 To compile, type gcc space 2d hyphen array dot c space hyphen o space arr and press Enter.
03:28 To execute, type dot slash arr (./arr), now press Enter .
03:34 Here we see Enter the elements of 3 into 4 array num1.
03:39 I will enter the values now.
03:52 Now we can see Enter the elements of 3 into 4 array num2.
03:57 I will enter the values.
04:10 The output is displayed.
04:13 Here we can see the num1 matrix.
04:16 Here we can see the num2 matrix.
04:20 And this is the sum of num1 and num2.
04:24 Now we will see how to execute the same program in C++.
04:29 I have already made the program. I will open it and explain.
04:34 This is the program for 2 Dimensional arrays in C++.
04:38 Note that our file name is 2d hyphen array dot cpp.
04:43 The extension is dot cpp (.cpp).
04:47 Let me explain the code now.
04:50 This is our header file as iostream.
04:53 This is our using statement.
04:56 This is our main() function.
04:58 Here we have cout function as we use cout to print the output in C++.
05:06 Then we have cin function. We use cin to read a line in C++.
05:13 Here, we use / t bit mean horizontal tab that is equivalent to 4 spaces.
05:21 Rest of the code is similar to our C code.
05:25 Now click on Save.
05:27 Let us execute. Come back to a terminal.
05:31 Let me clear the prompt.
05:33 To compile, type g++ space 2d hyphen array dot cpp hyphen o space arr1 and press Enter.
05:47 To execute, type dot slash arr1, now press Enter.
05:52 Here we see Enter the elements of 3 into 4 array num1.
05:57 I will enter the values.
06:07 Now, we see Enter the elements of 3 into 4 array num2.
06:13 I will give the values as:
06:24 The output is displayed.
06:26 We can see the num1 matrix, the num2 matrix.
06:31 And this is the sum of num1 and num2.
06:36 This brings us to the end of this tutorial.
06:39 Come back to our slide. Let us Summarize.
06:43 In this tutorial we learnt:
06:45 To add elements in a 2D array.
06:48 To print 2D array.
06:50 And to calculate the sum of 2Dimensional array.
06:54 As an assignment: Write the program that takes two 2Dimensional arrays as input from the user.
07:01 Subtract them and find the result.
07:05 Watch the video available at the link shown below:
07:08 It summarizes the Spoken Tutorial project.
07:11 If you do not have good bandwidth, you can download and watch it.
07:15 The Spoken Tutorial Project Team:
07:17 Conducts workshops using spoken tutorials.
07:21 Gives certificates to those who pass an online test.
07:25 For more details, please write to, contact@spoken-tutorial.org.
07:32 Spoken Tutorial Project is a part of Talk to a Teacher project.
07:36 It is supported by the National Mission on Education through ICT, MHRD, Government of India.
07:43 More information on this mission is available at the link shown below.
07:48 The script is contributed by Ritwik Joshi. This is Ashwini Patil from IIT Bombay.
07:54 Thank you for watching.

Contributors and Content Editors

Krupali, PoojaMoolya, Pratik kamble, Sandhya.np14, Sneha