Difference between revisions of "Advanced-C++/C2/Exception-Handling/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
 
(9 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
 
 
{| border=1
 
{| border=1
|  '''Visual Cue'''
+
|  '''Time'''
 
|  '''Narration'''
 
|  '''Narration'''
  
 
|-
 
|-
 
| 00:01
 
| 00:01
|  Welcome to the spoken tutorial on Exception Handling in C++.
+
|  Welcome to the '''spoken tutorial''' on '''Exception Handling''' in '''C++'''.
  
 
|-
 
|-
 
| 00:07
 
| 00:07
|  In this tutorial we will learn,
+
|  In this tutorial, we will learn
  
 
|-
 
|-
 
| 00:09
 
| 00:09
|Exception Handling.
+
|'''Exception Handling.'''
  
 
|-
 
|-
Line 23: Line 21:
 
|-
 
|-
 
| 00:14
 
| 00:14
|  To record this tutorial, I am using
+
|  To record this tutorial, I am using:
  
 
|-
 
|-
 
| 00:16
 
| 00:16
|'''Ubuntu OS '''version 11.10
+
|'''Ubuntu OS '''version '''11.10'''
  
 
|-
 
|-
 
| 00:20
 
| 00:20
|'''g++ compiler '''v. 4.6.1
+
|'''g++ compiler '''version '''4.6.1'''
  
 
|-
 
|-
 
| 00:25
 
| 00:25
|  Let us start with an introduction to '''Exception'''
+
|  Let us start with an introduction to '''Exception'''.
  
 
|-
 
|-
 
| 00:29
 
| 00:29
|An exception is a problem that arises during the execution of a program
+
|An '''exception''' is a problem that arises during the execution of a program.
  
 
|-
 
|-
 
| 00:34
 
| 00:34
|It is a run-time error that a program may detect
+
|It is a '''run-time error''' that a program may detect.
  
 
|-
 
|-
 
| 00:39
 
| 00:39
|  Let us move on to exception handling
+
|  Let us move on to '''exception handling'''.
  
 
|-
 
|-
 
| 00:42
 
| 00:42
|The response given to the problems occured during the execution of the program is known as  exception handling.
+
|The response given to the problems occurred during the execution of the program is known as  '''exception handling.'''
  
 
|-
 
|-
 
| 00:50
 
| 00:50
|Exception handling allows a program to continue execution.
+
|'''Exception handling''' allows a program to continue execution.
  
 
|-
 
|-
 
| 00:55
 
| 00:55
|It helps Identifying the problem.
+
|It helps identifying the problem.
  
 
|-
 
|-
Line 66: Line 64:
  
 
|-
 
|-
| 01:02  
+
|01:02  
| Let us see the Types of Exceptions
+
|Let us see the types of '''Exceptions'''-
  
 
|-
 
|-
 
| 01:05
 
| 01:05
|'''Try'''
+
|'''Try''''''Catch''' and
 
+
|-
+
| 01:06
+
|'''Catch'''
+
  
 
|-
 
|-
 
| 01:07
 
| 01:07
|And '''Throw'''
+
|'''Throw'''.
  
 
|-
 
|-
 
| 01:09
 
| 01:09
|We place the error prone code inside a try block
+
|We place the '''error''' prone '''code''' inside a '''try block'''.
  
 
|-
 
|-
 
| 01:13
 
| 01:13
|Then it is Handled using throw.  
+
|Then it is handled using '''throw.'''
  
 
|-
 
|-
 
| 01:16
 
| 01:16
|After this the exception is caught, using the catch statement
+
|After this, the '''exception''' is caught using the '''catch''' statement.
  
 
|-
 
|-
Line 99: Line 93:
 
|-
 
|-
 
| 01:23
 
| 01:23
|  The syntax for try, catch and throw is:
+
|  The '''syntax''' for '''try, catch''' and '''throw''' is:
  
 
|-
 
|-
 
| 01:27
 
| 01:27
|Throw:
+
|'''throw:'''The '''try block''' and the '''catch block'''.
 
+
 
+
|-
+
| 01:28
+
|The try block and the catch block
+
  
 
|-
 
|-
 
| 01:32
 
| 01:32
|Here we pass argument
+
|Here, we pass '''argument'''.
  
 
|-
 
|-
 
| 01:35  
 
| 01:35  
|The throw statement can be written inside the try block as well
+
|The '''throw''' statement can be written inside the '''try block''' as well.
  
 
|-
 
|-
 
| 01:40
 
| 01:40
|We can have more than try, catch blocks.
+
|We can have more than one '''try, catch'''  blocks.
  
 
|-
 
|-
 
| 01:44  
 
| 01:44  
|  Now let us see an example on exception handling.
+
|  Now, let us see an example on '''exception handling.'''
  
 
|-
 
|-
 
| 01:48
 
| 01:48
|I have the code, i'll open it
+
|I have the code, I will open it.
  
 
|-
 
|-
 
| 01:51  
 
| 01:51  
|  Note that our filename is '''exception.cpp'''
+
|  Note that our file name is '''exception.cpp'''.
  
 
|-
 
|-
 
| 01:55
 
| 01:55
|In this program we will solve the divide by zero error using exception handling.
+
|In this program, we will solve the 'divide by zero' '''error''' using '''exception handling.'''
  
 
|-
 
|-
 
| 02:02
 
| 02:02
|Let us go through the code
+
|Let us go through the '''code'''.
  
 
|-
 
|-
Line 152: Line 141:
 
|-
 
|-
 
| 02:11  
 
| 02:11  
|  Here we have function '''division''' with '''argument '''as''' int a''' and '''int b.'''
+
|  Here we have function '''division()''' with '''argument '''as''' int a''' and '''int b.'''
  
 
|-
 
|-
Line 160: Line 149:
 
|-
 
|-
 
| 02:22
 
| 02:22
|If true, we throw an exception division by zero condition
+
|If '''True''', we '''throw''' an '''exception''' "Division by zero condition!".
  
 
|-
 
|-
 
| 02:27
 
| 02:27
|The function returns division of''' a '''and''' b'''
+
|The function returns division of''' a '''and''' b'''.
  
 
|-
 
|-
 
| 02:32  
 
| 02:32  
|  This is our main function.
+
|  This is our '''main()''' function.
  
 
|-
 
|-
 
| 02:34
 
| 02:34
|  In this we have declared integer variables as '''x,''' '''y '''and a double variable as ''' z.'''
+
|  In this, we have declared '''integer variables''' as '''x,''' '''y '''and a '''double variable''' as ''' z.'''
  
 
|-
 
|-
 
| 02:42
 
| 02:42
 
|Here we accept the value of''' x '''and''' y.'''
 
|Here we accept the value of''' x '''and''' y.'''
 
 
 
  
 
|-
 
|-
 
| 02:46
 
| 02:46
|  This is our '''try block'''
+
|  This is our '''try block'''.
  
 
|-
 
|-
 
| 02:48
 
| 02:48
|Here we have called the function''' division.'''
+
|Here, we have called the function''' division()'''
  
 
|-
 
|-
 
| 02:51
 
| 02:51
|And stored the result in '''z.'''
+
|and stored the result in '''z.'''
  
 
|-
 
|-
Line 203: Line 189:
 
|-
 
|-
 
| 02:59
 
| 02:59
|In this we pass an''' argument msg '''as a''' character constant.'''
+
|In this, we pass an''' argument 'msg' ''' as a''' character constant.'''
  
 
|-
 
|-
Line 211: Line 197:
 
|-
 
|-
 
| 03:08
 
| 03:08
|  And this is our return statement.
+
|  And this is our '''return''' statement.
  
 
|-
 
|-
 
| 03:11
 
| 03:11
| Noe let us execute the program
+
| Now, let us '''execute''' the program.
  
 
|-
 
|-
 
| 03:13
 
| 03:13
|  Open the terminal by pressing '''Ctrl, Alt and T '''keys simultaneously on your keyboard
+
|  Open the '''terminal''' window by pressing '''Ctrl, Alt''' and '''T '''keys simultaneously on your keyboard.
  
 
|-
 
|-
 
| 03:21
 
| 03:21
|  To compile type  
+
|  To compile, type:
'''g++ space exception dot cpp space hyphen o space ex''' '''Press Enter'''.
+
'''g++ space exception dot cpp space hyphen o space ex'''. Press '''Enter'''.
  
 
|-
 
|-
 
| 03:32
 
| 03:32
|Type
+
|Type: '''dot slash ex''', press '''Enter'''.
'''dot slash ex''' '''Press Enter'''.
+
  
 
|-
 
|-
 
| 03:36
 
| 03:36
|'''Enter the value of x and y:'''
+
|'''Enter the value of x and y'''
  
 
|-
 
|-
 
| 03:38
 
| 03:38
|'''I will give as 3 and 0'''
+
|I will give as 3 and 0.
  
 
|-
 
|-
 
| 03:42
 
| 03:42
|The output is displayed as: '''Division by zero condition'''
+
|The '''output''' is displayed as: '''Division by zero condition!'''
  
 
|-
 
|-
 
| 03:46
 
| 03:46
|'''Let us compile again'''
+
|Let us compile again.
  
 
|-
 
|-
 
| 03:48
 
| 03:48
|'''Press the up arrow key twice '''
+
|Press the up-arrow key twice.
  
 
|-
 
|-
 
| 03:51
 
| 03:51
|'''Press enter
+
|Press '''Enter'''.Again press the up-arrow key twice.
|-
+
| 03:52
+
|Again press the up arrow key twice'''
+
  
 
|-
 
|-
Line 264: Line 246:
 
|-
 
|-
 
| 03:57
 
| 03:57
|'''i will give as 8 and 2'''
+
|I will give as 8 and 2.
  
 
|-
 
|-
 
| 04:01
 
| 04:01
|'''The output is 4'''
+
|The output is 4.
  
 
|-
 
|-
 
| 04:04  
 
| 04:04  
|  This is how the try catch and throw block works.
+
|  This is how the '''try, catch''' and '''throw block''' work.
  
 
|-
 
|-
Line 280: Line 262:
 
|-
 
|-
 
| 04:11
 
| 04:11
|Let us come back to our slides
+
|Let us come back to our '''slides'''.
  
 
|-
 
|-
 
| 04:14
 
| 04:14
|  Let us summarize,
+
|  Let us summarize.
  
 
|-
 
|-
 
| 04:16
 
| 04:16
|In this tutorial, we have seen, '''Exception Handling''' '''Try''' '''Catch''' and '''Throw blocks'''.
+
|In this tutorial, we have seen- '''Exception Handling''', '''try''', '''catch''' and '''throw blocks'''.
  
 
|-
 
|-
 
| 04:23
 
| 04:23
|  As an assignment  
+
|  As an assignment- Display the age of employees.
Display the age of employess.
+
  
 
|-
 
|-
 
| 04:26
 
| 04:26
|Throw an exception to check that the age is not less than 15.
+
|'''Throw''' an '''exception''' to check that the age is not less than 15.
  
 
|-
 
|-
 
| 04:31
 
| 04:31
|  Watch the video available at the link shown  
+
|  Watch the video available at the link shown below.
  
 
|-
 
|-
 
| 04:34
 
| 04:34
|It summarizes the Spoken Tutorial project  
+
|It summarizes the Spoken-Tutorial project.
  
 
|-
 
|-
 
| 04:38
 
| 04:38
|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.
  
 
|-
 
|-
 
| 04:42
 
| 04:42
| The Spoken Tutorial Project Team conducts workshops using spoken tutorials  
+
|The Spoken Tutorial Project team: conducts workshops using spoken tutorials.
  
 
|-
 
|-
 
| 04:48
 
| 04:48
|Gives certificates to those who pass an online test  
+
|Gives certificates to those who pass an online test.
  
 
|-
 
|-
 
| 04:52
 
| 04:52
|For more details, please write to, contact@spoken-tutorial.org
+
|For more details, please write to: contact@spoken-tutorial.org
  
 
|-
 
|-
 
| 04:59
 
| 04:59
|  Spoken Tutorial Project is a part of the Talk to a Teacher project
+
|  Spoken Tutorial Project is a part of the "Talk to a Teacher" project.
  
 
|-
 
|-
 
| 05:04
 
| 05:04
|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.
  
 
|-
 
|-
 
| 05:11
 
| 05:11
|More information on this Mission is available at the link shown below: [http://spoken-tutorial.org/NMEICT-Intro http://spoken-tutorial.org\NMEICT-Intro]
+
|More information on this mission is available at the link shown below: http://spoken-tutorial.org/NMEICT-Intro  
  
 
|-
 
|-
 
| 05:16
 
| 05:16
| This is Ashwini Patil from IIT Bombay signing off
+
|This is Ashwini Patil from IIT Bombay, signing off.Thank You for joining.  
 
+
Thank You for joining.  
+
  
 
|}
 
|}

Latest revision as of 15:10, 23 March 2017

Time Narration
00:01 Welcome to the spoken tutorial on Exception Handling in C++.
00:07 In this tutorial, we will learn
00:09 Exception Handling.
00:11 We will do this with the help of an example.
00:14 To record this tutorial, I am using:
00:16 Ubuntu OS version 11.10
00:20 g++ compiler version 4.6.1
00:25 Let us start with an introduction to Exception.
00:29 An exception is a problem that arises during the execution of a program.
00:34 It is a run-time error that a program may detect.
00:39 Let us move on to exception handling.
00:42 The response given to the problems occurred during the execution of the program is known as exception handling.
00:50 Exception handling allows a program to continue execution.
00:55 It helps identifying the problem.
00:57 And terminates the program in a controlled manner.
01:02 Let us see the types of Exceptions-
01:05 'Try'Catch and
01:07 Throw.
01:09 We place the error prone code inside a try block.
01:13 Then it is handled using throw.
01:16 After this, the exception is caught using the catch statement.
01:21 And then it is processed.
01:23 The syntax for try, catch and throw is:
01:27 throw:The try block and the catch block.
01:32 Here, we pass argument.
01:35 The throw statement can be written inside the try block as well.
01:40 We can have more than one try, catch blocks.
01:44 Now, let us see an example on exception handling.
01:48 I have the code, I will open it.
01:51 Note that our file name is exception.cpp.
01:55 In this program, we will solve the 'divide by zero' error using exception handling.
02:02 Let us go through the code.
02:04 This is our header file as iostream.
02:07 Here we are using the std namespace.
02:11 Here we have function division() with argument as int a and int b.
02:18 Then we check whether b ==0.
02:22 If True, we throw an exception "Division by zero condition!".
02:27 The function returns division of a and b.
02:32 This is our main() function.
02:34 In this, we have declared integer variables as x, y and a double variable as z.
02:42 Here we accept the value of x and y.
02:46 This is our try block.
02:48 Here, we have called the function division()
02:51 and stored the result in z.
02:54 Then we print the value of z.
02:57 This is our catch block.
02:59 In this, we pass an argument 'msg' as a character constant.
03:06 Then we print the msg.
03:08 And this is our return statement.
03:11 Now, let us execute the program.
03:13 Open the terminal window by pressing Ctrl, Alt and T keys simultaneously on your keyboard.
03:21 To compile, type:

g++ space exception dot cpp space hyphen o space ex. Press Enter.

03:32 Type: dot slash ex, press Enter.
03:36 Enter the value of x and y
03:38 I will give as 3 and 0.
03:42 The output is displayed as: Division by zero condition!
03:46 Let us compile again.
03:48 Press the up-arrow key twice.
03:51 Press Enter.Again press the up-arrow key twice.
03:55 Enter value of x and y
03:57 I will give as 8 and 2.
04:01 The output is 4.
04:04 This is how the try, catch and throw block work.
04:08 This brings us to the end of this tutorial.
04:11 Let us come back to our slides.
04:14 Let us summarize.
04:16 In this tutorial, we have seen- Exception Handling, try, catch and throw blocks.
04:23 As an assignment- Display the age of employees.
04:26 Throw an exception to check that the age is not less than 15.
04:31 Watch the video available at the link shown below.
04:34 It summarizes the Spoken-Tutorial project.
04:38 If you do not have good bandwidth, you can download and watch it.
04:42 The Spoken Tutorial Project team: conducts workshops using spoken tutorials.
04:48 Gives certificates to those who pass an online test.
04:52 For more details, please write to: contact@spoken-tutorial.org
04:59 Spoken Tutorial Project is a part of the "Talk to a Teacher" project.
05:04 It is supported by the National Mission on Education through ICT, MHRD, Government of India.
05:11 More information on this mission is available at the link shown below: http://spoken-tutorial.org/NMEICT-Intro
05:16 This is Ashwini Patil from IIT Bombay, signing off.Thank You for joining.

Contributors and Content Editors

Gaurav, PoojaMoolya, Pratik kamble, Sandhya.np14