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

From Script | Spoken-Tutorial
Jump to: navigation, search
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{| border = 1
 
{| border = 1
 
 
|'''Time'''
 
|'''Time'''
 
 
|'''Narration'''
 
|'''Narration'''
 
  
 
|-
 
|-
| 00.01
+
| 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.10
+
| 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.18
+
| 00:18
| Ubuntu Operating System version 11.10,  
+
| '''Ubuntu Operating System''' version 11.10,  
  
 
|-
 
|-
| 00.22
+
| 00:22
|gcc and g++ Compiler version 4.6.1 on Ubuntu  
+
|'''gcc''' and '''g++ Compiler''' version 4.6.1 on Ubuntu.
  
 
|-
 
|-
| 00.29
+
| 00:29
| Let us start with the introduction to 2 dimensional Array
+
| Let us start with the introduction to '''2 dimensional Array'''.
  
 
|-
 
|-
| 00.33
+
| 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.41
+
|00:41
 
|The right index indicates the column.  
 
|The right index indicates the column.  
  
 
|-
 
|-
|00.44
+
|00:44
|Starting index of a matrix or array in C and C++ is always 0
+
|Starting index of a matrix or array in C and C++ is always 0.
  
 
|-
 
|-
|00.52
+
|00:52
|Here we see a 2 Dimensional array in a row column matrix  
+
|Here, we see a 2 Dimensional array in a row column matrix.
  
 
|-
 
|-
| 00.58
+
| 00:58
|Starting index is 0
+
|Starting index is 0.
  
 
|-
 
|-
|01.01
+
|01:01
|Now, let us see how to declare 2 dimensional array
+
|Now, let us see how to declare '''2 dimensional array'''.
  
 
|-
 
|-
| 01.04
+
| 01:04
 
|The Syntax for this is:  
 
|The Syntax for this is:  
  
 
|-
 
|-
| 01.07
+
| 01:07
|data-type ,array name, row and column.
+
|'''data-type ,array name, row and column.'''
  
 
|-
 
|-
|01.13
+
|01:13
|example, here we have declare a 2 Dimensional array num with 2 rows and 3 columns
+
|example, here we have declared a 2 dimensional array '''num''' with 2 rows and 3 columns.
  
 
|-
 
|-
| 01.21
+
| 01:21
 
|Now let us see an example.
 
|Now let us see an example.
  
 
|-
 
|-
| 01.23
+
| 01:23
 
|I have already typed the program, let me open it.
 
|I have already typed the program, let me open it.
  
 
|-
 
|-
|01.28
+
|01:28
|Note that our file name is 2d hypen array dot c
+
|Note that our file name is '''2d hyphen array dot c'''.
  
 
|-
 
|-
|01.33
+
|01:33
|In this program we will calculate the sum of the elements of the 2 Dimensional array.
+
|In this program, we will calculate the sum of the elements of the 2 dimensional array.
  
 
|-
 
|-
|01.41
+
|01:41
 
|Let me explain the code now.
 
|Let me explain the code now.
  
 
|-
 
|-
|01.44
+
|01:44
|This is our header file.
+
|This is our '''header file.'''
  
 
|-
 
|-
|01.46
+
|01:46
|This is our main function.  
+
|This is our '''main()''' function.  
  
 
|-
 
|-
|01.49
+
|01:49
|Here, we have declared variable i and j.  
+
|Here we have declared variables i and j.  
  
 
|-
 
|-
| 01.53
+
| 01:53
|Then we have declared num1 with 3 rows and 4 columns  
+
|Then we have declared num1 with 3 rows and 4 columns.
  
 
|-
 
|-
| 01.58
+
| 01:58
|And num2 again with 3rows and 4columns
+
|And num2, again with 3 rows and 4 columns.
  
 
|-
 
|-
| 02.03
+
| 02:03
|num1 and num2 are 2 Dimensional array
+
|num1 and num2 are 2 dimensional arrays.
  
 
|-
 
|-
| 02.07
+
| 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.13
+
|02:13
 
|The elements are stored row-wise.  
 
|The elements are stored row-wise.  
  
 
|-
 
|-
|02.16
+
|02:16
 
|We have considered i for rows and j for columns.
 
|We have considered i for rows and j for columns.
  
 
|-
 
|-
|02.22
+
|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.33
+
| 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.40
+
| 02:40
| Here we display the matrix num1  
+
| Here we display the matrix num1.
  
 
|-
 
|-
| 02.43
+
| 02:43
 
|  Here percent 3d is used to align the matrix on the terminal.
 
|  Here percent 3d is used to align the matrix on the terminal.
  
 
|-
 
|-
| 02.49
+
| 02:49
| Now,here we display the matrix num2  
+
| Now, here we display the matrix num2.
  
 
|-
 
|-
|02.52
+
|02:52
 
|Then we add the num1 matrix and the num2 matrix and display the result.
 
|Then we add the num1 matrix and the num2 matrix and display the result.
  
 
|-
 
|-
| 02.59
+
| 02:59
| This is our return statement.  
+
| This is our '''return''' statement.  
  
 
|-
 
|-
| 03.01
+
| 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.07
+
| 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, gcc space 2d hypen array dot c space hypen o space arr and press Enter.
+
| To compile, type '''gcc''' space '''2d''' hyphen '''array''' dot '''c''' space '''hyphen o''' space''' arr''' and press '''Enter.'''
  
 
|-
 
|-
| 03.28
+
| 03:28
|To execute type, dot slash arr, now press Enter  
+
|To execute, type '''dot slash arr''' (./arr), now press '''Enter '''.
  
 
|-
 
|-
| 03.34
+
| 03:34
|Here we see Enter the elements of 3 into 4 array num1
+
|Here we see '''Enter the elements of 3 into 4 array num1'''.
  
 
|-
 
|-
| 03.39
+
| 03:39
 
| I will enter the values now.
 
| I will enter the values now.
  
 
|-
 
|-
| 03.52
+
| 03:52
| Now we can see enter the elements of 3 into 4 array num2
+
| Now we can see '''Enter the elements of 3 into 4 array num2'''.
 
+
  
 
|-
 
|-
| 03.57
+
| 03:57
|I will enter the values
+
|I will enter the values.
  
 
|-
 
|-
| 04.10
+
| 04:10
 
| The output is displayed.
 
| The output is displayed.
 
  
 
|-
 
|-
| 04.13
+
| 04:13
|Here we can see the num1 matrix
+
|Here we can see the num1 matrix.
 
   
 
   
 
|-
 
|-
| 04.16
+
| 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.29
+
| 04:29
|I have already made 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 2 Dimensional arrays in C++
+
|This is the program for '''2 Dimensional arrays''' in C++.
  
 
|-
 
|-
| 04.38
+
| 04:38
| Note that our file name is 2D hypen array dot cpp
+
| Note that our file name is''' 2d hyphen array dot cpp'''.
  
 
|-
 
|-
| 04.43
+
| 04:43
|The extension is dot cpp.
+
|The extension is '''dot cpp''' (.cpp).  
  
 
|-
 
|-
| 04.47
+
| 04:47
|Let me explain the code now
+
|Let me explain the code now.
  
 
|-
 
|-
| 04.50
+
| 04:50
|This is our header file as iostream
+
|This is our header file as '''iostream'''.
  
 
|-
 
|-
| 04.53
+
| 04:53
|This is our using statement.  
+
|This is our '''using''' statement.  
  
 
|-
 
|-
| 04.56
+
| 04:56
|This is our main function
+
|This is our '''main()''' function.
 
+
  
 
|-
 
|-
| 04.58
+
| 04:58
|Here we have cout function as we use cout to print the output in C++.
+
|Here we have '''cout''' function as we use '''cout''' to print the output in C++.
  
 
|-
 
|-
| 05.06
+
| 05:06
|Then we have cin function. We use cin to read  a line in C++
+
|Then we have '''cin''' function. We use '''cin''' to read  a line in C++.
  
 
|-
 
|-
| 05.13
+
| 05:13
|Here,we use  slash t it mean horizontal tab that is equivalent to 4 spaces.  
+
|Here, we use  '''/ t ''' bit mean horizontal tab that is equivalent to 4 spaces.  
  
 
|-
 
|-
| 05.21
+
| 05:21
 
|Rest of the code is similar to our C code.
 
|Rest of the code is similar to our C code.
  
 
|-
 
|-
| 05.25
+
| 05:25
|Now click on Save
+
|Now click on Save.
  
 
|-
 
|-
| 05.27
+
| 05:27
|Let us execute  
+
|Let us execute. Come back to a terminal.
  
 
|-
 
|-
| 05.28
+
| 05:31
|Come back to a 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.33
+
| 05:47
|To comple type, g++ space 2D hypen array dot cpp  hypen o space arr1 and press Enter.  
+
|To execute, type '''dot slash arr1''', now press Enter.
  
 
|-
 
|-
| 05.47
+
| 05:52
|To execute type, dot slash arr1, now press Enter.
+
|Here we see '''Enter the elements of 3 into 4 array num1.'''
  
 
|-
 
|-
| 05.52
+
| 05:57
|Here we see Enter the elements of 3 into 4 array num1.
+
|I will enter the values.
  
 
|-
 
|-
| 05.57
+
| 06:07
|I will enter the values
+
|Now, we see '''Enter the elements of 3 into 4 array num2.'''
  
 
|-
 
|-
| 06.07
+
| 06:13
|Now, we see Enter the elements of 3 into 4 array num2.
+
|I will give the values as:
 
+
  
 
|-
 
|-
| 06.13
+
| 06:24
|I wil give the values as
+
|The output is displayed.
  
 
|-
 
|-
| 06.24
+
| 06:26
|The output is displayed
+
 
+
|-
+
| 06.26
+
 
|We can see the num1 matrix, the num2 matrix.
 
|We can see the num1 matrix, the num2 matrix.
  
 
|-
 
|-
| 06.31
+
| 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 slide. Let us Summarize
+
|Come back to our slide. Let us Summarize.
  
 
|-
 
|-
| 06.43
+
| 06:43
|In this turoial 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.48
+
| 06:48
 
|To print 2D array.  
 
|To print 2D array.  
  
 
|-
 
|-
| 06.50
+
| 06:50
|And,to calculate the sum of 2Dimensional array.  
+
|And to calculate the sum of 2Dimensional array.  
 
+
|-
+
| 06.54
+
|As an assignment,
+
  
 
|-
 
|-
| 06.55
+
| 06:54
| Write the  program that takes two 2Dimensional arrays as input from the user.  
+
|As an assignment: Write the  program that takes two 2Dimensional arrays as input from the user.  
  
 
|-
 
|-
| 07.01
+
| 07:01
 
|Subtract them and find the result.  
 
|Subtract them and find the result.  
  
 
|-
 
|-
| 07.05
+
| 07:05
|Watch the video available at the link shown below
+
|Watch the video available at the link shown below:
  
 
|-
 
|-
| 07.08
+
| 07:08
|It summarizes the Spoken Tutorial project  
+
|It summarizes the Spoken Tutorial project.
  
 
|-
 
|-
| 07.11
+
| 07:11
|If you do not have good bandwidth, you can download and watch it  
+
|If you do not have good bandwidth, you can download and watch it.
  
 
|-
 
|-
| 07.15
+
| 07:15
|The Spoken Tutorial Project Team  
+
|The Spoken Tutorial Project Team:
  
 
|-
 
|-
| 07.17
+
| 07:17
|Conducts workshops using spoken tutorials  
+
|Conducts workshops using spoken tutorials.
  
 
|-
 
|-
| 07.21
+
| 07:21
|Gives certificates to those who pass an online test  
+
|Gives certificates to those who pass an online test.
  
 
|-
 
|-
| 07.25
+
| 07:25
|For more details, please write to, contact@spoken-tutorial.org  
+
|For more details, please write to, contact@spoken-tutorial.org.
  
 
|-
 
|-
|07.32
+
|07:32
|Spoken Tutorial Project is a part of Talk to a Teacher project  
+
|Spoken Tutorial Project is a part of Talk to a Teacher project.
  
 
|-
 
|-
| 07.36
+
| 07:36
|It is supported by the National Mission on Education through ICT, MHRD, Government of India
+
|It is supported by the National Mission on Education through ICT, MHRD, Government of India.
  
 
|-
 
|-
| 07.43
+
| 07:43
|More information on this Mission is available at the link shown below
+
|More information on this mission is available at the link shown below.
  
 
|-
 
|-
| 07.48
+
| 07:48
|The script is contributed by Ritwik Joshi. This is Ashwini Patil from IIT Bombay.  
+
|The script is contributed by Ritwik Joshi. This is Ashwini Patil from IIT Bombay.  
  
 
|-
 
|-
| 07.54
+
| 07:54
 
|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