Difference between revisions of "C-and-C++/C2/Tokens/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
Line 1: Line 1:
 
{| border=1
 
{| border=1
|| '''Time'''
+
|| Time
|| '''Narration'''
+
|| Narration
 
|-
 
|-
| 00.01  
+
| 00:01  
 
| Welcome to the spoken tutorial on '''Tokens-in-C-and-C-Plus-Plus''
 
| Welcome to the spoken tutorial on '''Tokens-in-C-and-C-Plus-Plus''
  
 
|-
 
|-
|00.06
+
|00:06
 
| In this tutorial we will learn ,
 
| In this tutorial we will learn ,
  
 
|-
 
|-
|00.09
+
|00:09
 
|How to define and use '''tokens.'''
 
|How to define and use '''tokens.'''
  
 
|-
 
|-
|00.12
+
|00:12
 
| We will do this with the help of an example.
 
| We will do this with the help of an example.
  
 
|-
 
|-
|00.15
+
|00:15
 
| We will also see some common errors and their solutions.
 
| We will also see some common errors and their solutions.
  
 
|-
 
|-
| 00.20
+
| 00:20
 
| To record this tutorial,
 
| To record this tutorial,
 
|-
 
|-
|00.21
+
|00:21
 
| I am using Ubuntu Operating system version 11.10
 
| I am using Ubuntu Operating system version 11.10
  
 
|-
 
|-
|00.26
+
|00:26
 
| gcc and g++ Compiler version 4.6.1.
 
| gcc and g++ Compiler version 4.6.1.
  
 
|-
 
|-
|00.33
+
|00:33
 
| Let us start with an introduction
 
| Let us start with an introduction
  
 
|-
 
|-
|00.36
+
|00:36
 
| Token is a generic word for '''Data types''', '''Variables''', '''Constants''' and '''Identifiers'''
 
| Token is a generic word for '''Data types''', '''Variables''', '''Constants''' and '''Identifiers'''
  
 
|-
 
|-
|00.46
+
|00:46
 
| Let us start with our program  
 
| Let us start with our program  
 
|-
 
|-
|00.49
+
|00:49
 
| I have already typed the code on the editor
 
| I have already typed the code on the editor
  
 
|-
 
|-
|00.53
+
|00:53
 
| Let me open it.  
 
| Let me open it.  
  
 
|-
 
|-
|00.56
+
|00:56
 
| Note that our file name is'' Tokens .c''.
 
| Note that our file name is'' Tokens .c''.
  
 
|-
 
|-
|01.04
+
|01:04
 
| In this program we will initialize the variables and print their values .
 
| In this program we will initialize the variables and print their values .
  
 
|-
 
|-
|01.09
+
|01:09
 
| Let me explain the code now.  
 
| Let me explain the code now.  
  
 
|-
 
|-
|01.12
+
|01:12
 
| This is our header file.
 
| This is our header file.
  
 
|-
 
|-
|01.16
+
|01:16
 
| This is our main functions.  
 
| This is our main functions.  
  
 
|-
 
|-
| 01.20
+
| 01:20
 
|Here,''' int '''is a '''keyword'''
 
|Here,''' int '''is a '''keyword'''
  
 
|-
 
|-
|01.22
+
|01:22
 
| The '''compiler''' knows the meaning of '''keywords'''.
 
| The '''compiler''' knows the meaning of '''keywords'''.
  
 
|-
 
|-
| 01.26
+
| 01:26
 
| '''a''' is an integer '''variable'''  
 
| '''a''' is an integer '''variable'''  
  
 
|-
 
|-
| 01.28
+
| 01:28
 
| | We have assigned a value of '''2 '''to it.
 
| | We have assigned a value of '''2 '''to it.
  
 
|-
 
|-
|01.32
+
|01:32
 
| This is called as initialization.
 
| This is called as initialization.
  
 
|-
 
|-
| 01.35
+
| 01:35
 
|If a value is not assigned to a variable then it is called as declaration of the variable.  
 
|If a value is not assigned to a variable then it is called as declaration of the variable.  
  
 
|-
 
|-
|01.43
+
|01:43
 
| Here, b is a constant.
 
| Here, b is a constant.
  
 
|-
 
|-
| 01.46
+
| 01:46
 
| We have initialized b, by assigning a value of 4 to it.
 
| We have initialized b, by assigning a value of 4 to it.
  
 
|-
 
|-
|01.53
+
|01:53
 
| const keyword is used to create read only variable
 
| const keyword is used to create read only variable
  
 
|-
 
|-
|01.58
+
|01:58
 
| Let us switch back to our slides to know more about keywords and constant.  
 
| Let us switch back to our slides to know more about keywords and constant.  
  
 
|-
 
|-
| 02.06
+
| 02:06
 
| '''Keywords''' have fixed meanings that cannot be changed
 
| '''Keywords''' have fixed meanings that cannot be changed
  
 
|-
 
|-
|02.11
+
|02:11
 
| '''Keywords''' cannot be used as '''variable''' names
 
| '''Keywords''' cannot be used as '''variable''' names
  
 
|-
 
|-
|02.15
+
|02:15
 
| There are 32''' keywords''' in C
 
| There are 32''' keywords''' in C
  
 
|-
 
|-
|02.18
+
|02:18
 
| To name some, '''auto''', '''break''', '''case''', '''char''', '''enum''', '''extern''', etc.
 
| To name some, '''auto''', '''break''', '''case''', '''char''', '''enum''', '''extern''', etc.
  
 
|-
 
|-
| 02.28
+
| 02:28
 
|Constants, Constants are fixed values.
 
|Constants, Constants are fixed values.
  
 
|-
 
|-
|02.33
+
|02:33
 
| They do not change during the execution of a program.  
 
| They do not change during the execution of a program.  
  
 
|-
 
|-
|02.38
+
|02:38
 
| There are two types of constants , Numeric constants and Character constants.  
 
| There are two types of constants , Numeric constants and Character constants.  
  
 
|-
 
|-
|02.45
+
|02:45
 
| Now come back to our program.
 
| Now come back to our program.
  
 
|-
 
|-
| 02.47
+
| 02:47
 
|'Here, float is a data type of variable c.
 
|'Here, float is a data type of variable c.
  
 
|-
 
|-
|02.52
+
|02:52
 
| We have assigned it a value of , '''1.5'''
 
| We have assigned it a value of , '''1.5'''
  
 
|-
 
|-
|02.56
+
|02:56
 
| '''Data type '''is a finite set of values along with a set of rules
 
| '''Data type '''is a finite set of values along with a set of rules
  
 
|-
 
|-
| 03.04
+
| 03:04
 
| Here, '''d '''is a '''variable'''
 
| Here, '''d '''is a '''variable'''
  
 
|-
 
|-
|03.07
+
|03:07
 
| '''Char''' and single quotes suggest that we are dealing with a '''character'''
 
| '''Char''' and single quotes suggest that we are dealing with a '''character'''
  
 
|-
 
|-
|03.12
+
|03:12
 
| As a result, '''d''' is a '''character variable ''' storing the value ''''A''''
 
| As a result, '''d''' is a '''character variable ''' storing the value ''''A''''
  
 
|-
 
|-
| 03.20
+
| 03:20
 
| It is easy to see that '''int, double float''' and char are datatypes.  
 
| It is easy to see that '''int, double float''' and char are datatypes.  
  
 
|-
 
|-
|03.30
+
|03:30
 
| '''a,''' '''c and d''' are '''variables'''
 
| '''a,''' '''c and d''' are '''variables'''
  
 
|-
 
|-
|03.35
+
|03:35
 
| Now come back to our slides.
 
| Now come back to our slides.
  
 
|-
 
|-
| 03.37
+
| 03:37
 
|We will know more about datatypes and variable
 
|We will know more about datatypes and variable
  
 
|-
 
|-
|03.48
+
|03:48
 
|Data types: Let us begin with integer data type
 
|Data types: Let us begin with integer data type
  
 
|-
 
|-
|03.50
+
|03:50
 
|It is declared as int
 
|It is declared as int
 
|-
 
|-
|03.53
+
|03:53
 
| If we want to print an integer data type , we will use %d as the format specifier  
 
| If we want to print an integer data type , we will use %d as the format specifier  
  
 
|-
 
|-
| 04.01
+
| 04:01
 
| Similarly, we will use float and %f for floating point numbers
 
| Similarly, we will use float and %f for floating point numbers
  
 
|-
 
|-
|04.09
+
|04:09
 
|For character data type, we will  use char and %c
 
|For character data type, we will  use char and %c
  
 
|-
 
|-
|04.15
+
|04:15
 
| And For double data type, we will use double and %lf as the format specifier.
 
| And For double data type, we will use double and %lf as the format specifier.
 
|-
 
|-
|04.24
+
|04:24
 
| Now we will see the range of data types
 
| Now we will see the range of data types
  
 
|-
 
|-
|04.29
+
|04:29
 
| '''Integer''' data type has a range of this  
 
| '''Integer''' data type has a range of this  
  
 
|-
 
|-
|04.34
+
|04:34
 
| '''Floating point''' has a range of this  
 
| '''Floating point''' has a range of this  
  
 
|-
 
|-
|04.39
+
|04:39
 
| '''Character''' has a range of this
 
| '''Character''' has a range of this
  
 
|-
 
|-
|04.42
+
|04:42
 
| And '''Double''' has a range of this  
 
| And '''Double''' has a range of this  
  
 
|-
 
|-
| 04.47
+
| 04:47
 
|The values stored in the variable must not be greater or less than this range.  
 
|The values stored in the variable must not be greater or less than this range.  
  
 
|-
 
|-
|04.56
+
|04:56
 
| Now we will move on to variables.  
 
| Now we will move on to variables.  
  
 
|-
 
|-
|05.00
+
|05:00
 
| Variable is a data name.
 
| Variable is a data name.
  
 
|-
 
|-
|05.02
+
|05:02
 
|It may be used to store a data value .
 
|It may be used to store a data value .
  
 
|-
 
|-
|05.06
+
|05:06
 
|The values can change when a program runs.
 
|The values can change when a program runs.
 
|-
 
|-
|05.10
+
|05:10
 
| Before using a '''variable''' it must be declared
 
| Before using a '''variable''' it must be declared
  
 
|-
 
|-
|05.14
+
|05:14
 
| We should try to give meaningful names to '''variables'''
 
| We should try to give meaningful names to '''variables'''
  
 
|-
 
|-
|05.18
+
|05:18
 
| example '''john''', '''marks''', '''sum''' etc.  
 
| example '''john''', '''marks''', '''sum''' etc.  
  
 
|-
 
|-
|05.24
+
|05:24
 
| Now we will  move back to our program.
 
| Now we will  move back to our program.
  
 
|-
 
|-
| 05.27
+
| 05:27
 
| Here,''' printf''' is the '''identifier''' name for this function
 
| Here,''' printf''' is the '''identifier''' name for this function
  
Line 268: Line 268:
  
 
|-
 
|-
| 05.32
+
| 05:32
 
| |Come back to our slides.
 
| |Come back to our slides.
  
 
|-
 
|-
| 05.35
+
| 05:35
 
|  Let us know about identifiers.
 
|  Let us know about identifiers.
  
 
|-
 
|-
| 05.38
+
| 05:38
 
| '''Identifiers''' are user defined names
 
| '''Identifiers''' are user defined names
  
 
|-
 
|-
|05.41
+
|05:41
 
| An '''identifier '''consists of letters and digits  
 
| An '''identifier '''consists of letters and digits  
  
 
|-
 
|-
|05.46
+
|05:46
 
| Both uppercase and lowercase letters are permitted  
 
| Both uppercase and lowercase letters are permitted  
  
 
|-
 
|-
|05.51
+
|05:51
 
| First character must be an alphabet or underscore .
 
| First character must be an alphabet or underscore .
  
 
|-
 
|-
| 05.55
+
| 05:55
 
|Now Come back to our program
 
|Now Come back to our program
  
 
|-
 
|-
| 05.58
+
| 05:58
 
|Here we have initialized the variables and constants.  
 
|Here we have initialized the variables and constants.  
  
 
|-
 
|-
| 06.02
+
| 06:02
 
|Here we print them.  
 
|Here we print them.  
  
 
|-
 
|-
| 06.05
+
| 06:05
 
|And this is our return statement.  
 
|And this is our return statement.  
  
 
|-
 
|-
| 06.08
+
| 06:08
 
|Now click on save.
 
|Now click on save.
  
 
|-
 
|-
| 06.10
+
| 06:10
 
| Let us execute the program
 
| Let us execute the program
  
 
|-
 
|-
|06.12
+
|06:12
 
| 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.
  
 
|-
 
|-
|06.21  
+
|06:21  
 
| To compile ,Type '''gcc space tokens dot c space hyphen o tok''' press''' Enter'''
 
| To compile ,Type '''gcc space tokens dot c space hyphen o tok''' press''' Enter'''
  
 
|-
 
|-
| 06.30
+
| 06:30
 
| To execute type'''./tok'''(dot slash tok)
 
| To execute type'''./tok'''(dot slash tok)
  
 
|-
 
|-
| 06.35
+
| 06:35
 
| The output is displayed.
 
| The output is displayed.
  
 
|-
 
|-
|06.39
+
|06:39
 
| We can see that here we have six values after the decimal point.
 
| We can see that here we have six values after the decimal point.
  
 
|-
 
|-
|06.44
+
|06:44
 
| And here we have two values.
 
| And here we have two values.
  
 
|-
 
|-
| 06.48
+
| 06:48
 
| Now let us find out how this happened. Come back to our program.
 
| Now let us find out how this happened. Come back to our program.
  
 
|-
 
|-
| 06.54
+
| 06:54
 
| This is because we have '''% point 2f''' here.
 
| This is because we have '''% point 2f''' here.
  
 
|-
 
|-
|06.59
+
|06:59
 
| It denotes that we can print only two values after the decimal point.
 
| It denotes that we can print only two values after the decimal point.
  
  
 
|-
 
|-
| 07.04
+
| 07:04
 
|  Suppose here I want an output with three decimal places.
 
|  Suppose here I want an output with three decimal places.
  
 
|-
 
|-
| 07.09
+
| 07:09
 
| Let us replace % point 2f with % point 3f
 
| Let us replace % point 2f with % point 3f
  
 
|-
 
|-
|07.16
+
|07:16
 
| Now Click on '''Save'''
 
| Now Click on '''Save'''
  
 
|-
 
|-
|07.19
+
|07:19
 
| Come back to our terminal.
 
| Come back to our terminal.
  
 
|-
 
|-
|07.22
+
|07:22
 
|  Compile as before, execute as before.
 
|  Compile as before, execute as before.
  
 
|-
 
|-
| 07.28
+
| 07:28
 
|We see here three values after the decimal point.  
 
|We see here three values after the decimal point.  
  
 
|-
 
|-
|07.33
+
|07:33
 
|Now we will execute the same program in c++  
 
|Now we will execute the same program in c++  
  
  
 
|-
 
|-
|07.36
+
|07:36
 
| Come back to our program
 
| Come back to our program
  
 
|-
 
|-
| 07.40
+
| 07:40
 
| I will change a few things here
 
| I will change a few things here
  
 
|-
 
|-
| 07.42
+
| 07:42
 
| First press shift+ctrl+s keys simultaneously on your keyboard.
 
| First press shift+ctrl+s keys simultaneously on your keyboard.
  
 
|-
 
|-
| 07.50
+
| 07:50
 
| Now save the file with an extension .cpp and click on save  
 
| Now save the file with an extension .cpp and click on save  
 
|-
 
|-
| 07.58
+
| 07:58
 
|let us change the header file as iostream
 
|let us change the header file as iostream
 
|-
 
|-
| 08.03
+
| 08:03
 
| Now  include the '''using '''statement   
 
| Now  include the '''using '''statement   
  
 
|-
 
|-
| 08.08
+
| 08:08
 
| And click on Save.
 
| And click on Save.
  
  
 
|-
 
|-
| 08.11
+
| 08:11
 
|Now replace the '''printf '''statement with the  '''cout'''  statement
 
|Now replace the '''printf '''statement with the  '''cout'''  statement
  
 
|-
 
|-
|08.15
+
|08:15
 
| Since we use ''cout<< function''' to print a line in C++
 
| Since we use ''cout<< function''' to print a line in C++
 
|-
 
|-
| 08.21
+
| 08:21
 
| Click on Search for and replace text option  
 
| Click on Search for and replace text option  
  
 
|-
 
|-
| 08.27
+
| 08:27
 
| Type here printf opening bracket “(”  
 
| Type here printf opening bracket “(”  
 
|-
 
|-
| 08.33
+
| 08:33
 
| And here in this column type, cout and two opening angle brackets “<<”.  
 
| And here in this column type, cout and two opening angle brackets “<<”.  
 
|-
 
|-
| 08.40
+
| 08:40
 
| Now click on Replace All  and click on Close.
 
| Now click on Replace All  and click on Close.
  
 
|-
 
|-
| 08.45
+
| 08:45
 
| We don't need the '''format specifier''' and /n  
 
| We don't need the '''format specifier''' and /n  
  
 
|-
 
|-
|08.50
+
|08:50
 
| Let us delete them.  
 
| Let us delete them.  
  
 
|-
 
|-
|08.52
+
|08:52
 
| Now delete the comma and  type two opening angle brackets.
 
| Now delete the comma and  type two opening angle brackets.
  
  
 
|-
 
|-
| 09.01
+
| 09:01
 
|Click on Save. Now delete the closing bracket  
 
|Click on Save. Now delete the closing bracket  
  
  
 
|-
 
|-
|09.04
+
|09:04
 
| Type two opening angle brackets again.  
 
| Type two opening angle brackets again.  
  
  
 
|-
 
|-
|09.09
+
|09:09
 
| And within the double quotes type \n.  
 
| And within the double quotes type \n.  
  
 
|-
 
|-
|09.16
+
|09:16
 
| Now Click on Save
 
| Now Click on Save
  
  
 
|-
 
|-
|09.20
+
|09:20
 
|Let us execute the program. Come back to our terminal.
 
|Let us execute the program. Come back to our terminal.
  
 
|-
 
|-
| 09.24
+
| 09:24
 
|To compile , type g++ space  tokens dot cpp space  hyphen o space tok 1
 
|To compile , type g++ space  tokens dot cpp space  hyphen o space tok 1
  
  
 
|-
 
|-
|09.35
+
|09:35
 
| Here we have tok1 because we don't want to overwrite the output parameter tok for the file tokens.c  
 
| Here we have tok1 because we don't want to overwrite the output parameter tok for the file tokens.c  
  
 
|-
 
|-
|09.46
+
|09:46
 
| Now press Enter
 
| Now press Enter
  
 
|-
 
|-
|09.48
+
|09:48
 
| To execute.Type ./tok1 . Press Enter  
 
| To execute.Type ./tok1 . Press Enter  
 
|-
 
|-
| 09.55
+
| 09:55
 
| The output is displayed.
 
| The output is displayed.
  
  
 
|-
 
|-
|09.59
+
|09:59
 
| Now let us move on to some common errors which we can come across.  
 
| Now let us move on to some common errors which we can come across.  
  
 
|-
 
|-
|10.03
+
|10:03
 
| Come back to our program.
 
| Come back to our program.
  
 
|-
 
|-
|10.05
+
|10:05
 
|  Suppose here I will reassign a new value to b as 8.
 
|  Suppose here I will reassign a new value to b as 8.
  
 
|-
 
|-
|10.12
+
|10:12
 
| Now Click on Save. Let us see what happens.
 
| Now Click on Save. Let us see what happens.
  
 
|-
 
|-
| 10.15
+
| 10:15
 
| Come back to our terminal.  
 
| Come back to our terminal.  
  
 
|-
 
|-
| 10.17
+
| 10:17
 
| Let me clear the prompt.
 
| Let me clear the prompt.
  
 
|-
 
|-
| 10.22
+
| 10:22
 
| Now compile as before.
 
| Now compile as before.
  
 
|-
 
|-
|10.26
+
|10:26
 
| We see an error at line no.7 in our tokens. cpp file.
 
| We see an error at line no.7 in our tokens. cpp file.
  
 
|-
 
|-
| 10.32
+
| 10:32
 
| Assignment of read only variable b.   
 
| Assignment of read only variable b.   
  
 
|-
 
|-
|10.36
+
|10:36
 
|Come back to our program
 
|Come back to our program
 
|-
 
|-
| 10.39
+
| 10:39
 
| This is because b is a constant. Constants are  fixed values.
 
| This is because b is a constant. Constants are  fixed values.
 
|-
 
|-
|10.45
+
|10:45
 
|They do not change during the execution of program.
 
|They do not change during the execution of program.
  
 
|-
 
|-
| 10.49
+
| 10:49
 
| Hence it is giving an error. Let us fix the error.
 
| Hence it is giving an error. Let us fix the error.
  
 
|-
 
|-
| 10.54
+
| 10:54
 
|Delete this. Click on Save
 
|Delete this. Click on Save
  
 
|-
 
|-
| 10.57
+
| 10:57
 
| Let us execute again. Come back to our terminal
 
| Let us execute again. Come back to our terminal
  
 
|-
 
|-
| 11.01
+
| 11:01
 
|Compile as before.  
 
|Compile as before.  
  
 
|-
 
|-
| 11.03
+
| 11:03
 
|Execute as before. Yes it is working.
 
|Execute as before. Yes it is working.
  
 
|-
 
|-
|11.09
+
|11:09
 
| Now we will see another common error.
 
| Now we will see another common error.
  
 
|-
 
|-
| 11.12
+
| 11:12
 
|Switch back to our program.
 
|Switch back to our program.
  
 
|-
 
|-
|11.15
+
|11:15
 
| Suppose here I will miss the single quotes. Click on Save
 
| Suppose here I will miss the single quotes. Click on Save
  
 
|-
 
|-
| 11.21
+
| 11:21
 
| let us execute. Come back to our  terminal.
 
| let us execute. Come back to our  terminal.
  
 
|-
 
|-
| 11.25
+
| 11:25
 
|Compile as before.
 
|Compile as before.
  
 
|-
 
|-
| 11.28
+
| 11:28
 
| we see an error at line no.9 in our tokens dot cpp file.
 
| we see an error at line no.9 in our tokens dot cpp file.
  
 
|-
 
|-
|11.34
+
|11:34
 
|A was not declared in the scope. Come back to our program.
 
|A was not declared in the scope. Come back to our program.
  
 
|-
 
|-
|11.40
+
|11:40
 
| This is because anything within the single quotes is considered as a character value.  
 
| This is because anything within the single quotes is considered as a character value.  
  
 
|-
 
|-
|11.47
+
|11:47
 
| And here we have declared d as a character variable.
 
| And here we have declared d as a character variable.
  
 
|-
 
|-
| 11.53
+
| 11:53
 
| Let us fix the error. Type single quotes at line no.9 here.
 
| Let us fix the error. Type single quotes at line no.9 here.
  
 
|-
 
|-
|11.59
+
|11:59
 
|Now Click on Save . Let us execute .
 
|Now Click on Save . Let us execute .
  
 
|-
 
|-
|12.02
+
|12:02
 
|Come back to our terminal  
 
|Come back to our terminal  
  
 
|-
 
|-
|12.04
+
|12:04
 
|Now Compile as before  
 
|Now Compile as before  
  
 
|-
 
|-
|12.06
+
|12:06
 
|Execute as before. Yes it is working.  
 
|Execute as before. Yes it is working.  
  
 
|-
 
|-
|12.13
+
|12:13
 
|Now  switch back to our slides.  
 
|Now  switch back to our slides.  
  
 
|-
 
|-
|12.15
+
|12:15
 
| Let us summarize  
 
| Let us summarize  
  
 
|-
 
|-
|12.16
+
|12:16
 
| In this tutorial we learnt,  
 
| In this tutorial we learnt,  
  
 
|-
 
|-
|12.18
+
|12:18
 
| Data types eg. int, double, float etc.  
 
| Data types eg. int, double, float etc.  
  
 
|-
 
|-
|12.24
+
|12:24
 
| Variables eg. int a=2;  
 
| Variables eg. int a=2;  
  
 
|-
 
|-
|12.29
+
|12:29
 
| Identifiers eg. printf() and
 
| Identifiers eg. printf() and
 
|-  
 
|-  
|12.34
+
|12:34
 
| Constant eg. double const b=4;  
 
| Constant eg. double const b=4;  
  
 
|-
 
|-
| 12.40
+
| 12:40
 
| As an assignment
 
| As an assignment
  
 
|-
 
|-
|12.41
+
|12:41
 
| Write a  program to calculate the simple interest.
 
| Write a  program to calculate the simple interest.
  
 
|-
 
|-
|12.45
+
|12:45
 
| Hint:  principal * rate * time upon  100
 
| Hint:  principal * rate * time upon  100
  
 
|-
 
|-
|12.50
+
|12:50
 
|Watch the video available at the link shown below
 
|Watch the video available at the link shown below
  
 
|-
 
|-
|12.54
+
|12:54
 
| It summarises the Spoken Tutorial project  
 
| It summarises the Spoken Tutorial project  
  
 
|-
 
|-
|12.56
+
|12:56
 
| 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.
  
 
|-
 
|-
| 13.01
+
| 13:01
 
| The Spoken Tutorial Project Team  
 
| The Spoken Tutorial Project Team  
  
 
|-
 
|-
|13.03
+
|13:03
 
| Conducts workshops using spoken tutorials  
 
| Conducts workshops using spoken tutorials  
  
 
|-
 
|-
|13.07
+
|13:07
 
| Gives certificates to those who pass an online test  
 
| Gives certificates to those who pass an online test  
  
 
|-
 
|-
|13.10
+
|13:10
 
| For more details,please write to contact @spoken-tutorial.org
 
| For more details,please write to contact @spoken-tutorial.org
  
 
|-
 
|-
| 13.19
+
| 13:19
 
| 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
 
   
 
   
 
|-
 
|-
|13.24
+
|13:24
 
| 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
  
 
|-
 
|-
|13.30
+
|13:30
 
| More information on this Mission is available at the link  shown below
 
| More information on this Mission is available at the link  shown below
  
 
|-
 
|-
|13.35
+
|13:35
 
| Ashwini Patil from IIT Bombay signing off .Thank You for joining
 
| Ashwini Patil from IIT Bombay signing off .Thank You for joining
  
 
|}
 
|}

Revision as of 11:33, 23 June 2014

Time Narration
00:01 Welcome to the spoken tutorial on 'Tokens-in-C-and-C-Plus-Plus
00:06 In this tutorial we will learn ,
00:09 How to define and use tokens.
00:12 We will do this with the help of an example.
00:15 We will also see some common errors and their solutions.
00:20 To record this tutorial,
00:21 I am using Ubuntu Operating system version 11.10
00:26 gcc and g++ Compiler version 4.6.1.
00:33 Let us start with an introduction
00:36 Token is a generic word for Data types, Variables, Constants and Identifiers
00:46 Let us start with our program
00:49 I have already typed the code on the editor
00:53 Let me open it.
00:56 Note that our file name is Tokens .c.
01:04 In this program we will initialize the variables and print their values .
01:09 Let me explain the code now.
01:12 This is our header file.
01:16 This is our main functions.
01:20 Here, int is a keyword
01:22 The compiler knows the meaning of keywords.
01:26 a is an integer variable
01:28 We have assigned a value of 2 to it.
01:32 This is called as initialization.
01:35 If a value is not assigned to a variable then it is called as declaration of the variable.
01:43 Here, b is a constant.
01:46 We have initialized b, by assigning a value of 4 to it.
01:53 const keyword is used to create read only variable
01:58 Let us switch back to our slides to know more about keywords and constant.
02:06 Keywords have fixed meanings that cannot be changed
02:11 Keywords cannot be used as variable names
02:15 There are 32 keywords in C
02:18 To name some, auto, break, case, char, enum, extern, etc.
02:28 Constants, Constants are fixed values.
02:33 They do not change during the execution of a program.
02:38 There are two types of constants , Numeric constants and Character constants.
02:45 Now come back to our program.
02:47 'Here, float is a data type of variable c.
02:52 We have assigned it a value of , 1.5
02:56 Data type is a finite set of values along with a set of rules
03:04 Here, d is a variable
03:07 Char and single quotes suggest that we are dealing with a character
03:12 As a result, d is a character variable storing the value 'A'
03:20 It is easy to see that int, double float and char are datatypes.
03:30 a, c and d are variables
03:35 Now come back to our slides.
03:37 We will know more about datatypes and variable
03:48 Data types: Let us begin with integer data type
03:50 It is declared as int
03:53 If we want to print an integer data type , we will use %d as the format specifier
04:01 Similarly, we will use float and %f for floating point numbers
04:09 For character data type, we will use char and %c
04:15 And For double data type, we will use double and %lf as the format specifier.
04:24 Now we will see the range of data types
04:29 Integer data type has a range of this
04:34 Floating point has a range of this
04:39 Character has a range of this
04:42 And Double has a range of this
04:47 The values stored in the variable must not be greater or less than this range.
04:56 Now we will move on to variables.
05:00 Variable is a data name.
05:02 It may be used to store a data value .
05:06 The values can change when a program runs.
05:10 Before using a variable it must be declared
05:14 We should try to give meaningful names to variables
05:18 example john, marks, sum etc.
05:24 Now we will move back to our program.
05:27 Here, printf is the identifier name for this function


05:32 Come back to our slides.
05:35 Let us know about identifiers.
05:38 Identifiers are user defined names
05:41 An identifier consists of letters and digits
05:46 Both uppercase and lowercase letters are permitted
05:51 First character must be an alphabet or underscore .
05:55 Now Come back to our program
05:58 Here we have initialized the variables and constants.
06:02 Here we print them.
06:05 And this is our return statement.
06:08 Now click on save.
06:10 Let us execute the program
06:12 Please open the terminal window by pressing Ctrl, Alt and T keys simultaneously on your keyboard.
06:21 To compile ,Type gcc space tokens dot c space hyphen o tok press Enter
06:30 To execute type./tok(dot slash tok)
06:35 The output is displayed.
06:39 We can see that here we have six values after the decimal point.
06:44 And here we have two values.
06:48 Now let us find out how this happened. Come back to our program.
06:54 This is because we have % point 2f here.
06:59 It denotes that we can print only two values after the decimal point.


07:04 Suppose here I want an output with three decimal places.
07:09 Let us replace % point 2f with % point 3f
07:16 Now Click on Save
07:19 Come back to our terminal.
07:22 Compile as before, execute as before.
07:28 We see here three values after the decimal point.
07:33 Now we will execute the same program in c++


07:36 Come back to our program
07:40 I will change a few things here
07:42 First press shift+ctrl+s keys simultaneously on your keyboard.
07:50 Now save the file with an extension .cpp and click on save
07:58 let us change the header file as iostream
08:03 Now include the using statement
08:08 And click on Save.


08:11 Now replace the printf statement with the cout statement
08:15 Since we use cout<< function' to print a line in C++
08:21 Click on Search for and replace text option
08:27 Type here printf opening bracket “(”
08:33 And here in this column type, cout and two opening angle brackets “<<”.
08:40 Now click on Replace All and click on Close.
08:45 We don't need the format specifier and /n
08:50 Let us delete them.
08:52 Now delete the comma and type two opening angle brackets.


09:01 Click on Save. Now delete the closing bracket


09:04 Type two opening angle brackets again.


09:09 And within the double quotes type \n.
09:16 Now Click on Save


09:20 Let us execute the program. Come back to our terminal.
09:24 To compile , type g++ space tokens dot cpp space hyphen o space tok 1


09:35 Here we have tok1 because we don't want to overwrite the output parameter tok for the file tokens.c
09:46 Now press Enter
09:48 To execute.Type ./tok1 . Press Enter
09:55 The output is displayed.


09:59 Now let us move on to some common errors which we can come across.
10:03 Come back to our program.
10:05 Suppose here I will reassign a new value to b as 8.
10:12 Now Click on Save. Let us see what happens.
10:15 Come back to our terminal.
10:17 Let me clear the prompt.
10:22 Now compile as before.
10:26 We see an error at line no.7 in our tokens. cpp file.
10:32 Assignment of read only variable b.
10:36 Come back to our program
10:39 This is because b is a constant. Constants are fixed values.
10:45 They do not change during the execution of program.
10:49 Hence it is giving an error. Let us fix the error.
10:54 Delete this. Click on Save
10:57 Let us execute again. Come back to our terminal
11:01 Compile as before.
11:03 Execute as before. Yes it is working.
11:09 Now we will see another common error.
11:12 Switch back to our program.
11:15 Suppose here I will miss the single quotes. Click on Save
11:21 let us execute. Come back to our terminal.
11:25 Compile as before.
11:28 we see an error at line no.9 in our tokens dot cpp file.
11:34 A was not declared in the scope. Come back to our program.
11:40 This is because anything within the single quotes is considered as a character value.
11:47 And here we have declared d as a character variable.
11:53 Let us fix the error. Type single quotes at line no.9 here.
11:59 Now Click on Save . Let us execute .
12:02 Come back to our terminal
12:04 Now Compile as before
12:06 Execute as before. Yes it is working.
12:13 Now switch back to our slides.
12:15 Let us summarize
12:16 In this tutorial we learnt,
12:18 Data types eg. int, double, float etc.
12:24 Variables eg. int a=2;
12:29 Identifiers eg. printf() and
12:34 Constant eg. double const b=4;
12:40 As an assignment
12:41 Write a program to calculate the simple interest.
12:45 Hint: principal * rate * time upon 100
12:50 Watch the video available at the link shown below
12:54 It summarises the Spoken Tutorial project
12:56 If you do not have good bandwidth, you can download and watch it.
13:01 The Spoken Tutorial Project Team
13:03 Conducts workshops using spoken tutorials
13:07 Gives certificates to those who pass an online test
13:10 For more details,please write to contact @spoken-tutorial.org
13:19 Spoken Tutorial Project is a part of the Talk to a Teacher project
13:24 It is supported by the National Mission on Education through ICT, MHRD, Government of India
13:30 More information on this Mission is available at the link shown below
13:35 Ashwini Patil from IIT Bombay signing off .Thank You for joining

Contributors and Content Editors

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