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

From Script | Spoken-Tutorial
Jump to: navigation, search
Line 1: Line 1:
{| border=1
+
{| border = 1
|| ''Time'''
+
 
|| '''Narration'''
+
|'''Time'''
 +
 
 +
|'''Narration'''
  
|-
 
| 00:02
 
|  Welcome to the spoken-tutorial on '''2dimensional Arrays''' in '''C''' and '''C++.'''
 
  
 
|-
 
|-
|00:08
+
| 00.01
| In this tutorial we will learn,
+
|Welcome to the spoken-tutorial on 2Dimensional Arrays in C and C++.
  
 
|-
 
|-
| 00:11
+
| 00.08
| What is a 2dimensional '''array.'''
+
|In this tutorial we will learn, 
  
 
|-
 
|-
| 00:13
+
| 00.10
| We will do this through  an example.
+
|What is a 2Dimensional array.
  
 
|-
 
|-
| 00:16
+
| 00.13
| To record this tutorial, I am using
+
|We will do this through an example.
  
 
|-
 
|-
|00:19
+
| 00.16
| '''Ubuntu Operating System''' version 11.10,
+
|To record this tutorial, I am using
  
 
|-
 
|-
| 00:23
+
| 00.18
| '''gcc''' and '''g++''' '''Compiler''' version 4.6.1 on Ubuntu
+
| Ubuntu Operating System version 11.10,
  
 
|-
 
|-
| 00:30
+
| 00.22
| Let us start with the introduction to '''2 dimensional Array'''
+
|gcc and g++ Compiler version 4.6.1 on Ubuntu
  
 
|-
 
|-
| 00:34
+
| 00.29
| '''2-D arrays are stored in a row column matrix.'''
+
| Let us start with the introduction to 2 dimensional Array
  
 
|-
 
|-
| 00:38
+
| 00.33
| '''The left index indicates the row.'''
+
|2-D arrays are stored in a row column matrix.
  
 
|-
 
|-
| 00:42
+
|00.38
| '''The right index indicates the column.''' '
+
| The left index indicates the row.
  
  
 
+
|-
 +
|00.41
 +
|The right index indicates the column.
  
 
|-
 
|-
| 00:45
+
|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'''
+
|Here we see a 2 Dimensional array in a row column matrix
  
 
|-
 
|-
| 00:55
+
| 00.58
| In a row column matrix. Starting index is'''0'''
+
|Starting index is 0
  
 +
|-
 +
|01.01
 +
|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
+
| 01.07
| The Syntax for this is:
+
|data-type ,array name, row and column.
 +
 
 
|-
 
|-
| 01:07
+
|01.13
| ''' data-type arr_name[row] [col]; '''
+
|example, here we have declare a 2 Dimensional array num with 2 rows and 3 columns
  
 
|-
 
|-
| 01:13
+
| 01.21
| eg.'''  Here we have declare a 2 dimensional array    num[2][3]; '''
+
|Now let us see an example.
  
 
|-
 
|-
| 01:22
+
| 01.23
|Now let us see an example
+
|I have already typed the program, let me open it.
 +
 
 
|-
 
|-
| 01:24
+
|01.28
| I have already typed the program 
+
|Note that our file name is 2d hypen array dot c
 +
 
 
|-
 
|-
| 01:26
+
|01.33
|Let me  open it.
+
|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:28
+
|01.46
| Note that our file name is '''2d-array.c'''
+
|This is our main function.  
  
 
|-
 
|-
| 01:34
+
|01.49
|In this program we will calculate, the sum of the elements of the 2dimensional arrays.
+
|Here, we have declared variable i and j.  
  
 
|-
 
|-
| 01:41
+
| 01.53
| Let me explain the code now.
+
|Then we have declared num1 with 3 rows and 4 columns
 +
 
 
|-
 
|-
| 01:44
+
| 01.58
| | This is our '''header file.'''
+
|And num2 again with 3rows and 4columns
  
 
|-
 
|-
| 01:47
+
| 02.03
| This is our '''main function'''.
+
|num1 and num2 are 2 Dimensional array
  
 
|-
 
|-
|   01:49
+
| 02.07
| Here, we have declared variable '''i''' and '''j'''.
+
|Here we take elements of the matrix num1 as input from the user.  
  
 
|-
 
|-
| 01:53
+
|02.13
|Then we have declared num1 with 3rows and 4columns
+
|The elements are stored row-wise.
  
 
|-
 
|-
| 01:59
+
|02.16
| And num2  again with 3rows and 4columns
+
|We have considered i for rows and j for columns.
 
+
  
 
|-
 
|-
| 02:04
+
|02.22
| ''' num1''' and '''num2''' are 2dimensional arrays
+
|This for loop will check the condition that i runs from 0 to 2.
 +
 
 
|-
 
|-
| 02:08
+
| 02.28
|   Here we take elements of the matrix '''num1''' as input from the user.
+
|This for loop will check the condition that j runs from 0 to 3.  
  
 
|-
 
|-
| 02:14
+
| 02.33
| The elements are stored row-wise.
+
| Similarly,Here we take elements of the matrix num2 as input from the user.  
  
 
|-
 
|-
| 02:17
+
| 02.40
| We have considered''' i''' for rows and  ''' j '''for columns.
+
| Here we display the matrix num1
  
 
|-
 
|-
| 02:23
+
| 02.43
| This for loop will check the condition that '''i''' runs from 0 to 2.
+
| Here percent 3d is used to align the matrix on the terminal.
  
 
|-
 
|-
| 02:28
+
| 02.49
| This for loop will check the condition that''' j''' runs from 0 to 3.
+
| Now,here we display the matrix num2
  
 
|-
 
|-
| 02:34
+
|02.52
|Similarly,  here we take elements of the matrix '''num2''' as input from the user.
+
|Then we add the num1 matrix and the num2 matrix and display the result.
 
+
 
+
 
+
  
 
|-
 
|-
|   02:41
+
| 02.59
| Here we display the matrix '''num1'''
+
| This is our return statement.
  
 
|-
 
|-
| 02:44
+
| 03.01
|   Here''' %3d''' is used to align the matrix on the terminal.
+
|Now, click on Save.
|-
+
|  02:50
+
|  Now here we display the matrix '''num2 '''
+
  
 
|-
 
|-
| 02:53
+
| 03.05
| Then we add the '''num1''' matrix and the '''num2 '''matrix
+
| Let us execute the program.
  
 
|-
 
|-
| 02:57
+
| 03.07
| And  display the result
+
|Please open the terminal window by pressing Ctrl, Alt and T keys simultaneously on your keyboard.
  
 
|-
 
|-
| 03:00
+
| 03.15
| This is our return statement.
+
| To compile type, gcc space 2d hypen array dot c space hypen o space arr and press Enter.
  
 
|-
 
|-
| 03:02
+
| 03.28
| Now, click on '''Save.'''
+
|To execute type, dot slash arr, now press Enter
  
 
|-
 
|-
| 03:05
+
| 03.34
|   Let us execute the program.
+
|Here we see Enter the elements of 3 into 4 array num1
  
 
|-
 
|-
| 03:08
+
| 03.39
| Please open the terminal window by pressing '''Ctrl, Alt''' and '''T''' keys simultaneously on your keyboard.
+
| I will enter the values now.
  
 
|-
 
|-
| 03:15
+
| 03.52
| To compile type,
+
| Now we can see enter the elements of 3 into 4 array num2
 +
 
  
 
|-
 
|-
| 03:17
+
| 03.57
| '''gcc 2d-array.c -o arr''' and press '''enter'''
+
|I will enter the values
  
 
|-
 
|-
| 03:29
+
| 04.10
| To execute type, ./ arr now press '''enter'''.
+
| The output is displayed.
 +
 
  
 
|-
 
|-
| 03:34
+
| 04.13
| Here we see enter the element of''' 3 into 4 array num1'''.
+
|Here we can see the num1 matrix
|-
+
   
|  03:40
+
|I will enter the values now
+
 
|-
 
|-
| 03:52
+
| 04.16
|Now we can see enter the element of''' 3 into 4 array num2'''
+
|Here we can see the num2 matrix
  
 
|-
 
|-
| 03:58
+
| 04.20
| I will enter the  values.
+
|And this is the sum of num1 and num2
 +
   
 
|-
 
|-
| 04:11
+
| 04.24
|The output is displayed,
+
|Now we will see how to execute the same program in C++
  
 
|-
 
|-
| 04:13
+
| 04.29
|Here we can see the '''num1''' matrix.
+
|I have already made the program.I will open it and explain.
 +
 
 
|-
 
|-
| 04:17
+
| 04.34
|here we can see the '''num2''' matrix.
+
|This is the program for 2 Dimensional arrays in C++
 +
 
 
|-
 
|-
| 04:20
+
| 04.38
|And this is the sum of '''num1''' and '''num2'''
+
| Note that our file name is 2D hypen array dot cpp
 +
 
 
|-
 
|-
| 04:24
+
| 04.43
| Now  we will see how to execute the same program in C++.
+
|The extension is dot cpp.
 +
 
 
|-
 
|-
| 04:30
+
| 04.47
| I have already named the program. I will open it and explain.
+
|Let me explain the code now
  
 
|-
 
|-
| 04:34
+
| 04.50
|This is the program for 2dimensional arrays in C++.
+
|This is our header file as iostream
 +
 
 
|-
 
|-
| 04:39
+
| 04.53
|Note that our file name is ''2d-array.cpp'''. The extension is '''.cpp'''.
+
|This is our using statement.
|-
+
 
| 04:48
+
|  Let me explain the code now. This is our '''header file''' as '''iostream'''
+
+
 
|-
 
|-
| 04:53
+
| 04.56
| This is our '''using''' statement.
+
|This is our main function
|-
+
|04:56
+
|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
+
| Then we have '''cin'' function, we use '''cin'''  to read a line in C++
+
  
 
|-
 
|-
|05:14
+
| 05.06
|Here we use '''\t'''  it means horizontal tab that is equivalent to 4 spaces.
+
|Then we have cin function. We use cin to read  a line in C++
 +
 
 
|-
 
|-
| 05:21
+
| 05.13
Rest of the code is similar to our '''c ''code  .Now click on '''Save'''
+
|Here,we use slash t it mean horizontal tab that is equivalent to 4 spaces.  
+
 
 
|-
 
|-
| 05:27
+
| 05.21
| Let us execute 
+
|Rest of the code is similar to our C code.
  
 
|-
 
|-
| 05:29
+
| 05.25
| Come back to our terminal
+
|Now click on Save
  
 
|-
 
|-
| 05:31
+
| 05.27
| Let me clear the prompt.
+
|Let us execute
 +
 
 
|-
 
|-
| 05:34
+
| 05.28
| To compile type, g++ 2d- array.cpp -o arr1 and press enter.
+
|Come back to a terminal
  
 
|-
 
|-
| 05:47
+
| 05.31
| To execute type,  ./arr1. Now press enter.
+
|Let me clear the prompt
 +
 
 
|-
 
|-
| 05:53
+
| 05.33
| Here we see enter the element of 3 into 4 array num1.
+
|To comple type, g++ space 2D hypen array dot cpp  hypen o space arr1 and press Enter.  
 +
 
 
|-
 
|-
| 05:58
+
| 05.47
| I will enter the values.
+
|To execute type, dot slash arr1, now press Enter.
 +
 
 
|-
 
|-
| 06:08
+
| 05.52
| Now we see enter the elements of 3 into 4 array num2.
+
|Here we see Enter the elements of 3 into 4 array num1.
  
 
|-
 
|-
| 06:14
+
| 05.57
|I will give the values as
+
|I will enter the values
 +
 
 
|-
 
|-
| 06:24
+
| 06.07
| The output is displayed  , We can see the '''num1 matrx''', '''num2 matrix'''.
+
|Now, we see Enter the elements of 3 into 4 array num2.
 +
 
  
 
|-
 
|-
|06:32
+
| 06.13
| And this is the sum of num1 and num2.
+
|I wil give the values as
 +
 
 
|-
 
|-
|06:36
+
| 06.24
|This brings us to the end of this tutorial.
+
|The output is displayed
 +
 
 
|-
 
|-
| 06:39
+
| 06.26
|Come back to our slides. Let us summarises
+
|We can see the num1 matrix, the num2 matrix.
  
 
|-
 
|-
| 06:43
+
| 06.31
| In this tutprial we learnt,
+
|And this is the sum of num1 and num2.
  
 
|-
 
|-
| 06:45
+
| 06.36
| To add elements in a 2D array.
+
|This brings us to the end of this tutorial
  
 
|-
 
|-
| 06:49
+
| 06.39
| To print 2D array.
+
|Come back to our slide. Let us Summarize
  
 
|-
 
|-
| 06:51
+
| 06.43
| And To calculate the sum of 2D array.
+
|In this turoial we learnt,
 +
 
 
|-
 
|-
| 06:55
+
| 06.45
| As an assignment,
+
|To add elements in a 2D array.
  
 
|-
 
|-
| 06:56
+
| 06.48
| Write a program that takes two 2D arrays as input from the user.
+
|To print 2D array.  
  
 
|-
 
|-
| 07:02
+
| 06.50
| Subtract them and find the result.
+
|And,to calculate the sum of 2Dimensional array.  
  
 
|-
 
|-
| 07:05
+
| 06.54
| Watch the video available at the  link shown below 
+
|As an assignment,
  
 
|-
 
|-
| 07:08
+
| 06.55
| It summarises the Spoken Tutorial project
+
| Write the  program that takes two 2Dimensional arrays as input from the user.
  
 
|-
 
|-
| 07:11
+
| 07.01
| If you do not have good bandwidth, you can download and watch it
+
|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:16
+
| 07.11
| The Spoken Tutorial Project Team
+
|If you do not have good bandwidth, you can download and watch it
 +
 
 
|-
 
|-
| 07:18
+
| 07.15
| Conducts workshops using spoken tutorials
+
|The Spoken Tutorial Project Team
  
 
|-
 
|-
| 07:21
+
| 07.17
| Gives certificates for those who pass an online test
+
|Conducts workshops using spoken tutorials
  
 
|-
 
|-
|07:26
+
| 07.21
| For more details, please write to contact at spoken hyphen tutorial dot org
+
|Gives certificates to those who pass an online test
  
 
+
|-
 +
| 07.25
 +
|For more details, please write to, contact@spoken-tutorial.org
  
 
|-
 
|-
| 07:33 
+
|07.32
|   Spoken Tutorial Project is a part of the Talk to a Teacher project  
+
|Spoken Tutorial Project is a part of Talk to a Teacher project  
 +
 
 
|-
 
|-
|   07:37
+
| 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:44
+
| 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:49
+
| 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.  
  
Thank you for watching  
+
|-
 
+
| 07.54
|}
+
|Thank you for watching.

Revision as of 15:52, 21 November 2013

Time Narration


00.01 Welcome to the spoken-tutorial on 2Dimensional Arrays in C and C++.
00.08 In this tutorial we will learn,
00.10 What is a 2Dimensional 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 2-D 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 declare 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 hypen 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 variable i and j.
01.53 Then we have declared num1 with 3 rows and 4 columns
01.58 And num2 again with 3rows and 4columns
02.03 num1 and num2 are 2 Dimensional array
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 hypen array dot c space hypen o space arr and press Enter.
03.28 To execute type, dot slash 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 hypen array dot cpp
04.43 The extension is dot 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 slash t it 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
05.28 Come back to a terminal
05.31 Let me clear the prompt
05.33 To comple type, g++ space 2D hypen array dot cpp hypen 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 wil 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 turoial 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,
06.55 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