Difference between revisions of "C-and-C++/C4/Working-With-Structures/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
 
(10 intermediate revisions by 3 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 '''Structures '''in '''C''' and '''C++.'''
+
|Welcome to the spoken-tutorial on '''Structures''' in '''C and C++'''.
  
 
|-
 
|-
| 00:06
+
| 00:06
| In this tutorial we will learn
+
|In this tutorial we will learn
 
+
  
 
|-
 
|-
| 00:09
+
| 00:08
|   what is a '''Structure'''.
+
|What is a '''Structure. '''
 
+
  
 
|-
 
|-
| 00:11
+
| 00:10
| Declaration of a '''structure'''
+
|Declaration of a '''structure'''.
 
+
  
 
|-
 
|-
| 00:13
+
| 00:13
| We will do this through an example
+
|We will do this through an example.
 
+
 
+
 
+
  
 
|-
 
|-
| 00:16
+
| 00:15
| 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
+
| '''gcc '''and '''g++ Compiler''' version 4.6.1.
  
 
|-
 
|-
| 00:29
+
| 00:28
| Let us start with an introduction to '''Structure'''
+
|Let us start with an introduction to '''Structure '''.
 
+
  
 
|-
 
|-
| 00:32
+
|00:31
| When one or more variables are grouped under one name it is known as '''structure'''.
+
|When one or more variables are grouped under one name, it is known as '''structure.'''  
 
+
  
 
|-
 
|-
| 00:38
+
|00:37
| Strucutre is used to group different data into one object.
+
|Structure is used to group different data into one object.  
 
+
  
 
|-
 
|-
| 00:43
+
|00:42
| It is called as '''compound data-type'''.
+
|It is called as '''compound data-type.'''  
 
+
  
 
|-
 
|-
| 00:45
+
| 00:45
| It is used to group related information together.
+
|It is used to group related information together.  
  
 
|-
 
|-
| 00:49
+
| 00:49
|  Now we will see
+
|  Now we will see the syntax to declare a '''structure'''.
 
+
  
 
|-
 
|-
| 00:50
+
| 00:52
| The syntax to declare a '''structure'''
+
|Here, the keyword '''struct''' tells the compiler that a structure is declared.
 
+
  
 
|-
 
|-
| 00:53
+
| 00:59
| Here the keyword''' struct '''tells the compiler that a structure is declared
+
|'''strcut_name''' is the name of the '''structure.'''
 
+
  
 
|-
 
|-
| 00:59
+
| 01:02
| '''strcut_name''' is the name of the '''structure'''.
+
|eg. '''struct employee; '''
 
+
  
 
|-
 
|-
| 01:03
+
| 01:04
| eg. '''struct employee;'''
+
|You can give any name.
 
+
  
 
|-
 
|-
| 01:05
+
| 01:07
| You can give any name.
+
|Now we will see how to declare a '''structure''' variable.  
  
 
|-
 
|-
| 01:07
+
|01:10
| Now we will see how to declare a '''structure''' '''variable'''.
+
|The syntax for this is:
 
+
  
 
|-
 
|-
| 01:12
+
| 01:13
| Syntax for this is
+
|'''struct struct_name and  struct_var; '''
 
+
  
 
|-
 
|-
| 01:14
+
| 01:17
| '''struct struct_name  and struct_var;'''
+
|'''struct_var''' is the variable of type '''struc_name'''.
 
+
  
 
|-
 
|-
| 01:17
+
| 01:21
| '''struct_var''' is the variable of type '''struc_name'''
+
|example, '''struct employee addr; '''
 
+
  
 
|-
 
|-
| 01:22
+
| 01:26
| eg. '''struct employee addr;'''
+
|'''addr''' is the '''variable''' of type '''employee. '''
 
+
  
 
|-
 
|-
| 01:27
+
|01:30
| '''addr''' is the '''variable''' of type '''employee.'''
+
|Let us move on to our example.  
  
 
|-
 
|-
| 01:31
+
|01:33
| Let us move on to our example
+
|I have already typed the program on the editor. So, let me open it.
  
 
|-
 
|-
| 01:33
+
|01:37
|   I have already typed the program on the editor
+
|Note that our file name is '''structure.c.'''
 
+
  
 
|-
 
|-
| 01:36
+
|01:41
| So let me open it.  
+
|In this program we will calculate the total marks of three subjects using structure.  
  
 
|-
 
|-
| 01:38
+
|01:48
| Note that our filename is '''structure.c'''
+
|Let me explain the code now.  
  
 
|-
 
|-
|  01:42
+
|01:51
| In this program we will calculate the total marks of three subjects using structure
+
|This is our header file.
 
+
|-
+
|  01:49
+
|  Let me explain the code now.
+
 
+
|-
+
| 01:51
+
+
|   This is our header file.
+
  
 
|-
 
|-
 
| 01:53
 
| 01:53
| Here we have declared a '''structure '''as''' student'''.
+
|Here we have declared a '''structure''' as '''student.'''
 
+
 
+
 
+
  
 
|-
 
|-
| 01:57
+
| 01:57
|   Then we have declared three integer variables as '''english, maths '''and '''science'''.
+
| Then we have declared three integer variables as '''English, maths''' and '''science. '''  
 
+
  
 
|-
 
|-
| 02:04
+
| 02:03
| Variables defined under the structure are called as members of the structure.
+
|Variables defined under the structure are called as members of the structure.  
  
 
|-
 
|-
| 02:10
+
|02:09
| This is our main function  
+
|This is our main() function.
  
 
|-
 
|-
| 02:12
+
| 02:11
| Here we have declared an integer variable''' total'''.
+
| Here we have declared an '''integer''' variable 'total'.  
  
 
|-
 
|-
| 02:17
+
| 02:16
| Now we have declared a structure variable '''stud'''. ''' stud '''is the variable of type student,it is used to access and modify the structure members  
+
| Now we have declared a structure variable '''stud, stud''' is the variable of type student, it is used to access and modify the structure members.
 
+
 
+
 
+
  
 
|-
 
|-
| 02:30
+
| 02:28
| Here we have modified the members
+
| Here we have modified the members
  
 
|-
 
|-
| 02:32
+
| 02:31
|By assigning them values as 75, 70 and 65.  
+
|by assigning them values as 75, 70 and 65.  
  
 
|-
 
|-
| 02:38
+
| 02:37
|   Here we calculate the total of three subjects.
+
|Here we calculate the total of three subjects.  
  
 
|-
 
|-
| 02:42
+
| 02:41
|   Then we print the result.
+
|Then we print the result.  
  
 
|-
 
|-
|   02:44
+
| 02:44
| This is our return statement.
+
|This is our '''return''' statement.  
  
 
|-
 
|-
| 02:47
+
| 02:46
| Now click on '''Save'''
+
|Now click on '''Save '''.
  
 
|-
 
|-
| 02:49
+
| 02:48
|   Let us execute the program  
+
|Let us execute the program.
  
 
|-
 
|-
| 02:51
+
| 02:50
| Please open the terminal window by pressing
+
|Please open the terminal window by pressing  
  
 
|-
 
|-
| 02:54
+
| 02:54
|'''Ctrl, Alt''' and '''T''' keys simultaneously on your keyboard.
+
| '''Ctrl, Alt''' and '''T''' keys simultaneously on your keyboard.  
  
 
|-
 
|-
| 03:00
+
| 02:59
|   To compile  
+
| To compile, type '''gcc space structure.c space hyphen o space struct''' and press''' Enter'''.
  
 
|-
 
|-
| 03:01
+
| 03:12
|Type; '''gcc '''space '''structure.c '''space '''-o '''space''' struct'''
+
|To execute, type (dot slash)'''./struct.''' Press Enter.
  
 
|-
 
|-
| 03:10
+
| 03:17
|And press''' Enter'''
+
|The output is displayed as:
  
 
|-
 
|-
| 03:12
+
| 03:20
|To execute
+
|'''Total is 210'''
  
 
|-
 
|-
| 03:13
+
| 03:22
|Type'''./struct''' Press''' Enter '''
+
|Now we will execute the same program in C++ .
  
 
|-
 
|-
| 03:18
+
| 03:26
|   The output is displayed as: Total is 210
+
|Come back to our program.
  
 
|-
 
|-
| 03:22
+
| 03:28
| Now we will execute the same program in C++
+
|I will edit the same code.
  
 
|-
 
|-
| 03:26
+
| 03:30
| Come back to our program.
+
|First press '''Shift, Ctrl''' and  '''S''' keys simultaneously on the keyboard.  
  
 
|-
 
|-
| 03:28
+
| 03:37
|   I will edit the same code
+
|Now save the file with an extension '''.cpp '''
  
 
|-
 
|-
|   03:31
+
| 03:41
| First press '''shift''', '''cntrl '''and '''S''' keys simultaneously on the keyboard
+
| and click on save.
  
 
|-
 
|-
| 03:37
+
| 03:43
|Now save the file with an extension '''.cpp''' and click on save
+
| Let's change the header file as '''iostream'''.
  
 
|-
 
|-
| 03:44
+
| 03:47
| Let us change the header file as '''iostream'''
+
|Now include the '''using''' statement
  
 
|-
 
|-
| 03:48
+
| 03:53
| Now include the '''using''' statement and click on''' save'''
+
|and click on '''save'''.
  
 
|-
 
|-
| 03:57
+
| 03:56
| Structure declaration in '''C++ '''is same as in''' C'''
+
|Structure declaration in '''C++''' is same as in '''C'''.
  
 
|-
 
|-
| 04:02
+
| 04:01
|So no need to change anything here
+
|So, no need to change anything here.
  
 
|-
 
|-
 
| 04:05
 
| 04:05
|   At the end we will replace the printf statement with the ''' cout ''' statement.
+
|At the end we will replace the '''printf''' statement with the '''cout''' statement.  
  
 
|-
 
|-
| 04:08
+
| 04:12
|   Delete the format specifier and '''\n'''
+
|Delete the format specifier and (backslash n) \n.
  
 
|-
 
|-
| 04:16
+
| 04:15
|Now delete the comma
+
|Now delete the comma.
  
 
|-
 
|-
| 04:17
+
| 04:17
 
|Type two opening angle brackets.  
 
|Type two opening angle brackets.  
  
 
|-
 
|-
| 04:21
+
| 04:20
|Here delete the closing bracket  
+
|Here, delete the closing bracket  
  
 
|-
 
|-
| 04:23
+
| 04:22
|and type two opening angle backets
+
|and type two opening angle brackets.
  
 
|-
 
|-
| 04:25
+
| 04:25
|And within the double quotes type '''\n'''
+
|And within the double quotes, type \n (backslash n).
  
 
|-
 
|-
| 04:29
+
| 04:29
| Now click on '''Save'''
+
|Now click on '''Save'''.
  
 
|-
 
|-
|   04:31  
+
| 04:31
| Let us execute the program
+
|Let us execute the program.
  
 
|-
 
|-
|   04:33
+
| 04:33
|   Come back to our terminal
+
|Come back to our terminal.
  
 
|-
 
|-
| 04:35
+
| 04:35
|To compile type '''g++ '''space''' structure.cpp '''space '''-o '''space''' struct1'''
+
|To compile, type '''g++ space structure.cpp space hyphen o space struct1 '''.
  
 
|-
 
|-
| 04:47
+
| 04:46
|Here we have struct1 because we dont want to overwrite the output parameters for the file''' structure.c'''
+
| Here we have struct1 because we don't want to overwrite the output parameters '''struct''' for the file '''structure.c '''.
  
 
|-
 
|-
| 04:55
+
| 04:55
|Now press '''Enter'''
+
|Now press Enter.
  
 
|-
 
|-
| 04:57
+
| 04:57
|To execute type '''./struct1'''
+
|To execute, type (dot slash) '''./struct1'''. Press '''Enter'''.
  
 
|-
 
|-
| 05:02
+
| 05:03
|Press''' Enter '''
+
|The output is displayed as:
  
 
|-
 
|-
| 05:04
+
| 05:05
| The output is displayed as: '''Total is 210'''
+
|'''Total is 210'''
  
 
|-
 
|-
| 05:08  
+
| 05:08
|You can see that the output is same as our '''C '''code
+
|You can see that the output is same as our C code.
  
 
|-
 
|-
| 05:12
+
| 05:12
|Now let us go   back to our slides.
+
|Now let us go back to our slides.  
  
 
|-
 
|-
| 05:15
+
| 05:14
| We will summarize now. In this tutorial we learned,
+
|We will summarize now. In this tutorial we learned,  
  
 
|-
 
|-
| 05:18
+
| 05:18
|Structure.
+
|Structure, Syntax of a structure
  
 
|-
 
|-
| 05:19
+
| 05:20
|Syntax of a structure.
+
|eg. '''struct struct_name; '''
  
 
|-
 
|-
| 05:21
+
| 05:23
|eg. '''struct struct_name;'''
+
|To access members of a structure.  
  
 
|-
 
|-
| 05:24
+
| 05:25
|To access members of a structure.
+
|Eg: stud.maths = 75;
  
 
|-
 
|-
| 05:26
+
| 05:30
|'''Eg: stud.maths = 75; '''
+
|And to add the structure variables.  
  
 
|-
 
|-
| 05:30
+
| 05:33
|To add the structure variables.
+
|Eg: total = stud.eng + stud.maths + stud.science;
  
 
|-
 
|-
| 05:33
+
| 05:40
|'''Eg: total = stud.eng + stud.maths + stud.science; '''
+
|As an assignment, write a program to display  records of an employee.  
  
 
|-
 
|-
| 05:40
+
| 05:44
| | As an assignment,
+
|Like name, address, designation, and salary.
  
 
|-
 
|-
| 05:41
+
| 05:49
|Write a program to diplay the records of an employee.
+
|Watch the video available at the link shown below.
  
 
|-
 
|-
| 05:45
+
| 05:52
|Like name, address, designation, salary.
+
|It summarizes the Spoken Tutorial project.  
  
 
|-
 
|-
| 05:49
+
| 05:54
| Watch the video available at the link shown below
+
|If you do not have good bandwidth, you can download and watch it.
  
 
|-
 
|-
| 05:53
+
| 05:59
|It summarises the Spoken Tutorial project
+
|The Spoken Tutorial Project Team:
  
 
|-
 
|-
| 05:55
+
| 06:01
|If you do not have good bandwidth, you can download and watch it
+
|Conducts workshops using spoken tutorials.
  
 
|-
 
|-
| 06:00
+
|06:04
| | The Spoken Tutorial Project Team
+
|Gives certificates to those who pass an online test.
  
 
|-
 
|-
| 06:02
+
| 06:08
|Conducts workshops using spoken tutorials
+
|For more details, please write to, contact@spoken-tutorial.org.
 
+
|-
+
|  06:05
+
|Gives certificates to those who pass an online test
+
 
+
|-
+
06:08
+
|For more details, please write to contact@spoken-tutorial.org
+
  
 
|-
 
|-
 
| 06:15
 
| 06:15
| 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.
  
 
|-
 
|-
| 06:19
+
| 06:18
|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.
  
 
|-
 
|-
| 06:26
+
| 06:25
|More information on this Mission is available at: http://spoken-tutorial.org\NMEICT-Intro
+
|More information on this mission is available at the link shown below.
  
 
|-
 
|-
| 06:30
+
| 06:29
| This is Ashwini Patil from IIT Bombay. Siginning off.
+
| This is Ashwini Patil from IIT Bombay, signing off.  
  
 
|-
 
|-
| 06:33
+
| 06:33
|Thank You for joining
+
|Thank You for watching.
 
+
|}
+

Latest revision as of 14:47, 24 March 2017

Time Narration
00:01 Welcome to the spoken-tutorial on Structures in C and C++.
00:06 In this tutorial we will learn,
00:08 What is a Structure.
00:10 Declaration of a structure.
00:13 We will do this through an example.
00:15 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.
00:28 Let us start with an introduction to Structure .
00:31 When one or more variables are grouped under one name, it is known as structure.
00:37 Structure is used to group different data into one object.
00:42 It is called as compound data-type.
00:45 It is used to group related information together.
00:49 Now we will see the syntax to declare a structure.
00:52 Here, the keyword struct tells the compiler that a structure is declared.
00:59 strcut_name is the name of the structure.
01:02 eg. struct employee;
01:04 You can give any name.
01:07 Now we will see how to declare a structure variable.
01:10 The syntax for this is:
01:13 struct struct_name and struct_var;
01:17 struct_var is the variable of type struc_name.
01:21 example, struct employee addr;
01:26 addr is the variable of type employee.
01:30 Let us move on to our example.
01:33 I have already typed the program on the editor. So, let me open it.
01:37 Note that our file name is structure.c.
01:41 In this program we will calculate the total marks of three subjects using structure.
01:48 Let me explain the code now.
01:51 This is our header file.
01:53 Here we have declared a structure as student.
01:57 Then we have declared three integer variables as English, maths and science.
02:03 Variables defined under the structure are called as members of the structure.
02:09 This is our main() function.
02:11 Here we have declared an integer variable 'total'.
02:16 Now we have declared a structure variable stud, stud is the variable of type student, it is used to access and modify the structure members.
02:28 Here we have modified the members
02:31 by assigning them values as 75, 70 and 65.
02:37 Here we calculate the total of three subjects.
02:41 Then we print the result.
02:44 This is our return statement.
02:46 Now click on Save .
02:48 Let us execute the program.
02:50 Please open the terminal window by pressing
02:54 Ctrl, Alt and T keys simultaneously on your keyboard.
02:59 To compile, type gcc space structure.c space hyphen o space struct and press Enter.
03:12 To execute, type (dot slash)./struct. Press Enter.
03:17 The output is displayed as:
03:20 Total is 210
03:22 Now we will execute the same program in C++ .
03:26 Come back to our program.
03:28 I will edit the same code.
03:30 First press Shift, Ctrl and S keys simultaneously on the keyboard.
03:37 Now save the file with an extension .cpp
03:41 and click on save.
03:43 Let's change the header file as iostream.
03:47 Now include the using statement
03:53 and click on save.
03:56 Structure declaration in C++ is same as in C.
04:01 So, no need to change anything here.
04:05 At the end we will replace the printf statement with the cout statement.
04:12 Delete the format specifier and (backslash n) \n.
04:15 Now delete the comma.
04:17 Type two opening angle brackets.
04:20 Here, delete the closing bracket
04:22 and type two opening angle brackets.
04:25 And within the double quotes, type \n (backslash n).
04:29 Now click on Save.
04:31 Let us execute the program.
04:33 Come back to our terminal.
04:35 To compile, type g++ space structure.cpp space hyphen o space struct1 .
04:46 Here we have struct1 because we don't want to overwrite the output parameters struct for the file structure.c .
04:55 Now press Enter.
04:57 To execute, type (dot slash) ./struct1. Press Enter.
05:03 The output is displayed as:
05:05 Total is 210
05:08 You can see that the output is same as our C code.
05:12 Now let us go back to our slides.
05:14 We will summarize now. In this tutorial we learned,
05:18 Structure, Syntax of a structure
05:20 eg. struct struct_name;
05:23 To access members of a structure.
05:25 Eg: stud.maths = 75;
05:30 And to add the structure variables.
05:33 Eg: total = stud.eng + stud.maths + stud.science;
05:40 As an assignment, write a program to display records of an employee.
05:44 Like name, address, designation, and salary.
05:49 Watch the video available at the link shown below.
05:52 It summarizes the Spoken Tutorial project.
05:54 If you do not have good bandwidth, you can download and watch it.
05:59 The Spoken Tutorial Project Team:
06:01 Conducts workshops using spoken tutorials.
06:04 Gives certificates to those who pass an online test.
06:08 For more details, please write to, contact@spoken-tutorial.org.
06:15 Spoken Tutorial Project is a part of Talk to a Teacher project.
06:18 It is supported by the National Mission on Education through ICT, MHRD, Government of India.
06:25 More information on this mission is available at the link shown below.
06:29 This is Ashwini Patil from IIT Bombay, signing off.
06:33 Thank You for watching.

Contributors and Content Editors

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