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

From Script | Spoken-Tutorial
Jump to: navigation, search
 
(17 intermediate revisions by 7 users not shown)
Line 2: Line 2:
  
 
|'''Time'''
 
|'''Time'''
 
 
|'''Narration'''
 
|'''Narration'''
 
  
 
|-
 
|-
| 00.02
+
| 00:01
| | પ્રથમ C પ્રોગ્રામ પરના સ્પોકન ટ્યુટોરીયલમાં તમારું સ્વાગત છે.
+
| Welcome to the spoken tutorial on '''First C program'''.
  
 
|-
 
|-
| 00.06
+
| 00:05
| આ ટ્યુટોરીયલ માં, આપણે શીખીશું,
+
| In this tutorial, we  will learn
  
 
|-
 
|-
| 00.08
+
| 00:08
| સરળ C પ્રોગ્રામ કેવી રીતે લખવું 
+
| How to write a simple C program
  
 
|-
 
|-
| 00.11
+
| 00:11
| તેને કમ્પાઇલ કેવી રીતે કરવું
+
| How to compile it
  
 
|-
 
|-
| 00.13
+
| 00:13
| તેને એક્ઝેક્યુટ કેવી રીતે કરવું
+
| How to execute it We will also explain some common errors and their solutions.
  
 
|-
 
|-
| 00.14
+
|00:18
|આપણે કેટલીક સામાન્ય એરર અને તેના ઉકેલો પણ સમજીશું.
+
| To record this tutorial, I am using
  
 
|-
 
|-
|00.19
+
| 00:21
| | આ ટ્યુટોરીયલ રેકોર્ડ કરવા માટે, હું
+
|Ubuntu operating system version 11.10 and gcc Compiler version 4.6.1 on Ubuntu.
  
 
|-
 
|-
| 00.22
+
| 00:31
|ઉબુન્ટુ ઓપરેટીંગ સિસ્ટમ આવૃત્તિ 11.10 અને ઉબુન્ટુ પર GCC કમ્પાઈલર આવૃત્તિ 4.6.1 નો ઉપયોગ કરી રહ્યી છું.
+
| To practice this tutorial,
  
 
|-
 
|-
| 00.31
+
| 00:33
| આ ટ્યુટોરીયલનો અભ્યાસ કરવા માટે,
+
|You should be familiar with Ubuntu Operating System and an Editor.
  
 
|-
 
|-
| 00.33
+
| 00:38
|તમારે ઉબુન્ટુ ઓપરેટીંગ સિસ્ટમ અને એડિટર સાથે પરિચિત હોવું જોઈએ
+
|Some editors are '''vim''' and '''gedit'''.
  
 
|-
 
|-
| 00.39
+
| 00:42
|કેટલાક એડીટરો vim અને gedit છે
+
|I will use 'gedit' in this tutorial.
  
 
|-
 
|-
| 00.42
+
| 00:45
|આ ટ્યુટોરીયલ માં હું gedit નો ઉપયોગ કરીશ.
+
|For relevant tutorials please visit our website which is as shown. http://spoken-tutorial.org
  
 
|-
 
|-
| 00.46
+
|00:51
|સંબંધિત ટ્યુટોરિયલ્સ માટે અમારી વેબસાઇટ http://spoken-tutorial.org જુઓ.
+
| Let me tell you how to write a C program through an example.  
  
 
|-
 
|-
|00.51
+
| 00:55
| ચાલો હું એક ઉદાહરણ દ્વારા C પ્રોગ્રામ કેવી રીતે લખવું તે કહું.
+
|Open the terminal window  by pressing '''Ctrl, Alt and T '''keys simultaneously on your keyboard.
  
 
|-
 
|-
| 00.56
+
| 01:07
|તમારા કીબોર્ડ પર '''Ctrl, Alt અને T ''' કીઓ એકસાથે દબાવી ટર્મિનલ વિન્ડો ખોલો.
+
| Now let's open the text editor. So, at the prompt, type
  
 
|-
 
|-
| 01.07
+
| 01:12
| હવે ટેક્સ્ટ એડિટર ખોલો. તેથી, પ્રોમ્પ્ટ પર, ટાઇપ કરો,
+
|'''“gedit”''' space '''“talk”''' dot '''“c”''' space “&”''' sign.
  
 
|-
 
|-
| 01.12
+
| 01:20
|'''“gedit”''' space '''“talk”''' dot '''“c”''' space “&'''
+
|'''We use ampersand (&) to free up the prompt. '''
  
 
|-
 
|-
| 01.20
+
| 01:24
|પ્રોમ્પ્ટને મુક્ત કરવા માટે આપણે એમપરસેન્ડ (&) ચિહ્નનો ઉપયોગ કરીશું.
+
| Please note that all the '''C''' files will  have  extension  '''“.c”'''(dot C).
  
 
|-
 
|-
| 01.25
+
|01:30
| નોંધ લો કે બધી '''C''' ફાઈલને ડોટ '''C''' એક્સ્ટેંશન છે.
+
| Now Press '''Enter''',
  
 
|-
 
|-
|01.31
+
| 01:32
હવે એન્ટર ડબાઓ.  
+
the text editor has opened.
  
 
|-
 
|-
| 01.33
+
| 01:36
ટેક્સ્ટ એડિટર ખૂલેલ છે.
+
Let us start to write a program.  
  
 
|-
 
|-
| 01.37
+
| 01:39
| પ્રોગ્રામ લખવા માટે શરૂઆત કરીએ
+
| Type double slash '''“//”''' space
  
 
|-
 
|-
| 01.39
+
| 01:42
| ટાઇપ કરો, ડબલ સ્લેશ '''“//”''' space
+
|'''“My first C program”.'''
  
 
|-
 
|-
| 01.42
+
|01:48
|'''“My first C program”.'''
+
| Here, double slash is used to comment the line.
  
 
|-
 
|-
|01.48
+
| 01:52
| અહીં, ડબલ સ્લેશ લીટીને કમેન્ટ કરવા માટે વપરાય છે.
+
|Comments are used to understand the flow of program.
  
 
|-
 
|-
| 01.52
+
| 01:56
|કમેન્ટ્સ પ્રોગ્રામનો ફ્લો સમજવા માટે વપરાય છે
+
|It is useful for documentation.
  
 
|-
 
|-
| 01.56
+
| 01:58
|તે ડોકયુમેન્ટેશન માટે ઉપયોગી છે
+
|It gives us information about the program.
  
 
|-
 
|-
| 01.58
+
| 02:01
|તે આપણને પ્રોગ્રામ વિશે માહિતી આપે છે
+
|The double slash is called as single line comment.
  
 
|-
 
|-
| 02.01
+
| 02:07
|ડબલ સ્લેશ સિંગલ લાઈન કમેન્ટ તરીકે ઓળખવામાં આવે છે.
+
| Now press '''Enter'''.
  
 
|-
 
|-
| 02.07
+
|02:09
| હવે એન્ટર ડબાઓ.
+
|Type (hash) '''“#include”''' space opening bracket , closing bracket.  
  
 
|-
 
|-
|02.09
+
| 02:17
|ટાઇપ કરો, હેશ '''“include”''' સ્પેસ, ઑપનિંગ બ્રેકેટ, ક્લોસિંગ બ્રેકેટ,
+
| It is always a good practice to complete the brackets first, and then start writing inside it.
  
 
|-
 
|-
| 02.17
+
| 02:24
| પ્રથમ કૌંસ પૂર્ણ કરવું અને પછી તે અંદર લખવાનું શરૂ કરવું એ હંમેશા સારી પ્રેક્ટીસ છે,  
+
| Now Inside the bracket, type'''“stdio”''' “(dot).” “'''h” '''.
  
 
|-
 
|-
| 02.24
+
| 02:30
| હવે કૌશ અંદર, ટાઇપ કરો, '''“stdio”''' dot”.” “'''h” '''
+
| '''stdio.h''' is a '''header file'''.
  
 
|-
 
|-
| 02.30
+
| 02:33
| '''stdio.h''' એ હેડર ફાઈલ છે.
+
|A '''program''' must contain this header file when it uses standard '''input/output  functions'''.
  
 
|-
 
|-
| 02.34
+
| 02:41
|પ્રોગ્રામ આ હેડર ફાઈલ સમાવવું જ જોઈએ જયારે તે ઇનપુટ/આઉટપુટ ફ્ન્ક્શનોનો ઉપયોગ કરે છે. હવે એન્ટર દબાવો.
+
|Now press Enter.
  
 
|-
 
|-
| 02.43
+
| 02:43
ટાઇપ કરો, '''“int” ''' સ્પેસ ''' “main” ''' ઓપનીંગ બ્રેકેટ,
+
type '''“int” '''space''' “main” '''opening bracket, closing bracket.
  ક્લોસિંગ બ્રેકેટ '''“()”. '''
+
   
 
+
 
|-
 
|-
| 02.50
+
| 02:50
| | ' '''main''' એક ખાસ ફન્કશન છે.  
+
| | '''main''' is a special '''function'''.
 +
|-
 +
| 02:52
 +
|It denotes that the execution of the program begins from this line.
  
 
|-
 
|-
| 02.53
+
| 02:58
|તે સૂચવે છે કે પ્રોગ્રામનું એકઝીક્યુશન આ લીટીથી શરૂ થાય છે.
+
|The opening bracket and closing bracket is called as parenthesis.
+
 
 
|-
 
|-
| 02.58
+
| 03:04
|ઓપનીંગ બ્રેકેટ અને ક્લોસિંગ બ્રેકેટને પેરેનથીસીસ કહેવામાં આવે છે.
+
| Parenthesis followed by '''main''' is to tell the user that '''main''' is a '''function'''.
  
 
|-
 
|-
| 03.04
+
| 03:11
| '''main''' સાથે અનુસરતા પેરેનથીસીસ યુઝરને એ બતાવવા માટે છે કે '''main''' એક ફન્કશન છે.
+
| Here the '''int''' '''main function''' takes no '''arguments'''.  
  
 
|-
 
|-
| 03.11
+
| 03:15
| અહીં '''int''' '''main function''' કોઈ આરગ્યુંમેન્ટ નથી લેતું.
+
|It returns a value of type '''integer'''.
  
 
|-
 
|-
| 03.15
+
| 03:18
|તે '''integer''' ટાઇપની વેલ્યુ રીટર્ન કરે છે.
+
| We will learn about '''data types''' in another tutorial.
  
 
|-
 
|-
| 03.19
+
| 03:23
| '''data types''' વિષે આપને બીજા ટ્યુટોરીયલ માં શીખીશું.
+
| Now  Let us switch to the slides to know more about  '''main''' function. Let us go to the next slide.
  
 
|-
 
|-
| 03.23
+
| 03:29
| હવે '''main''' ફન્કશન વિષે વધુ જાણવા માટે ચાલો સ્લાઈડ ઉપર જઈએ. આગામી સ્લાઇડ પર જાઓ.
+
| Every '''program''' should have one main() function.
  
 
|-
 
|-
| 03.30
+
| 03:33
| દરેક '''પ્રોગ્રામ''' ને એક main ફન્કશન હોવું જોઈએ
+
|There should NOT be more than one main function.
  
 
|-
 
|-
| 03.33
+
| 03:36
|એક કરતાં વધુ main ફન્કશન ન હોવું જોઇએ
+
|Otherwise the compiler cannot locate the beginning of the program.
  
 
|-
 
|-
| 03.37
+
| 03:41
|નહિં તો કમ્પાઇલર પ્રોગ્રામની શરૂઆત સ્થિત ન કરી શકશે.
+
|The empty pair of parentheses indicates that main has no '''arguments'''.
  
 
|-
 
|-
| 03.41
+
| 03:46
|ખાલી પેરેન્થેસીસ સૂચવે છે કે main ફન્કશનને કોઈ આરગ્યુંમેન્ટ નથી.
+
|The concept of arguments will be discussed in detail in the upcoming tutorials.
  
 
|-
 
|-
| 03.47
+
| 03:52
|આરગ્યુંમેન્ટનો કોન્સેપ્ટ આગામી ટ્યુટોરિયલ્સ માં વિગતવાર ચર્ચા કરવામાં આવશે.
+
| Now let us come back to our program.  
  
 
|-
 
|-
| 03.52
+
| 03:55
| હવે આપણા પ્રોગ્રામ ઉપર પાછા આવીએ. એન્ટર દબાવો.
+
| Press '''Enter.'''
  
 
|-
 
|-
| 03.58
+
| 03:58
| ઓપન કર્લી બ્રેકેટ ટાઇપ કરો '''“{”'''
+
| Type opening curly bracket '''“{”'''.
  
 
|-
 
|-
| 04.00
+
| 04:00
|ઓપનીંગ કર્લી બ્રેકેટ '''main''' ફન્કશનની શરૂઆત ચિહ્નિત કરે છે.
+
|The opening curly bracket marks the beginning of the '''function''' '''main'''.
  
 
|-
 
|-
| 04.05
+
| 04:04
|પછી ક્લોસિંગ કર્લી બ્રેકેટ ટાઇપ કરો '''“}”'''
+
|Then  Type  closing curly  bracket '''“}”'''.
 
   
 
   
 
|-
 
|-
| 04.08
+
| 04:08
|ક્લોસિંગ કર્લી બ્રેકેટ '''main''' ફન્કશનનો અંત દર્શાવે છે.
+
|The closing curly bracket indicates the end of the '''function''' '''main'''.  
  
 
|-
 
|-
| 04.13
+
| 04:13
| હવે બ્રેકેટ અંદર,
+
| Now Inside the bracket  press '''Enter''' twice,
  
 
|-
 
|-
| 04.14
+
| 04:16
|બે વખત એન્ટર ડબાઓ,  કર્સરને એક લીટી ઉપર ખસેડો.
+
|move the cursor one line up.
  
 
|-
 
|-
| 04.20
+
| 04:20
| ઇન્ડેંટેશન કોડ વાંચવા માટે સરળ બનાવે છે
+
| Indentation makes the code easier to read.
  
 
|-
 
|-
| 04.23
+
| 04:23
|તે એરર પણ ઝડપથી સ્થિત કરવા માટે મદદ કરે છે
+
|It also helps to locate errors faster.
  
 
|-
 
|-
| 04.26
+
| 04:25
|તો ચાલો અહીં ત્રણ સ્પેસ આપીએ.
+
|So let us give three space here
  
 
|-
 
|-
| 04.29
+
| 04:29
| અને ટાઇપ કરો ''' “printf” ''' ઓપનીંગ બ્રેકેટ, ક્લોસિંગ બ્રેકેટ '''“()” '''
+
| And  Type''' “printf” ''' opening bracket closing bracket '''“()” '''.
  
 
|-
 
|-
| 04.34
+
| 04:34
|'''printf''' ટર્મિનલ પર આઉટપુટ પ્રિન્ટ કરવા માટે પ્રમાણભૂત C ફન્કશન છે
+
|'''printf '''is a standard C function to print the output on the terminal.
  
 
|-
 
|-
| 04.39
+
| 04:39
અહીં બ્રેકેટ અંદર, ડબલ અવતરણચિહ્નો ની અંદર,
+
Here, inside the brackets, within the double quotes.
  
 
|-
 
|-
| 04.44
+
| 04:43
|printf ફન્કશનમાં ડબલ અવતરણ ચિહ્ન અંદર આવેલ કંઈપણ ટર્મિનલ પર પ્રિન્ટ કરવામાં આવશે.
+
|Anything within the double quotes, in the printf statement, will be printed on the terminal.
  
 
|-
 
|-
| 04.50
+
| 04:50
|ટાઇપ કરો '''“Talk To a Teacher ''' બેકસ્લેશ '''n”'''
+
|Type'''“Talk To a Teacher '''backslash '''n”'''.
  
 
|-
 
|-
| 05.00
+
| 04:59
|બેકસ્લેશ n '''“\n” ''' નવી લીટી દર્શાવે છે.
+
|Backslash n '''“\n” '''signifies newline.
  
 
|-
 
|-
| 05.03
+
| 05:03
|પરિણામ સ્વરૂપે, printf ફન્કશનના એક્ઝીક્યુશન પછી, કર્સર નવી લીટી પર ખસે છે.
+
|As a result, after execution of the '''printf '''function, the cursor moves to the new line.
  
 
|-
 
|-
| 05.11
+
| 05:10
| દરેક C સ્ટેટમેન્ટ અર્ધવિરામ (semicolon) સાથે અંત થવું જોઈએ.
+
| Every '''C''' statement must end with a '''semicolon “;”'''.
  
 
|-
 
|-
| 05.15
+
| 05:15
|તેથી, આ લીટીના અંતે તે ટાઇપ કરો.
+
|Hence, type it at the end of this line.  
  
 
|-
 
|-
| 05.19
+
| 05:19
|અર્ધવિરામ સ્ટેટમેન્ટ ટર્મીનેટર તરીકે કામ કરે છે.
+
|'''Semicolon''' acts as a statement terminator.
  
 
|-
 
|-
|05.24
+
|05:24
|હવે એન્ટર ડબાઓ. અહીં ત્રણ સ્પેસ આપો,
+
|Now press '''Enter''' give three space here.
  
 
|-
 
|-
|05.28
+
|05:27
| અને ટાઇપ કરો '''“return”''' સ્પેસ ''' “0”''' અને '''અર્ધવિરામ''' '''“;”'''
+
| And type '''“return”''' space''' “0”''' and a '''semicolon'''.
  
 
|-
 
|-
| 05.34
+
| 05:34
| આ સ્ટેટમેન્ટ પૂર્ણાંક શૂન્ય આપે છે.
+
| This statement returns the integer zero.
  
 
|-
 
|-
| 05.38
+
| 05:38
| આ ફન્કશન માટે પૂર્ણાંક રીટર્ન કરવું જ જોઈએ કારણ કે ફન્કશન ટાઇપ '''int''' છે.
+
|An integer has to be returned for this function because the function type is '''int'''.
  
 
|-
 
|-
| 05.45
+
| 05:45
|The '''return''' statement marks the end of executable statements
+
|The '''return''' statement marks the end of executable statements.
  
 
|-
 
|-
| 05.51
+
| 05:51
 
|We will learn more about the returned values in another tutorial.
 
|We will learn more about the returned values in another tutorial.
  
 
|-
 
|-
| 05.56
+
| 05:55
| Now click on"'''Save'''" button to save the file  
+
| Now click on"'''Save'''" button to save the file.
  
 
|-
 
|-
| 06.00
+
| 06:00
|It is a good habit to save files frequently
+
|It is a good habit to save files frequently.
  
 
|-
 
|-
| 06.03
+
| 06:03
|This will protect you from sudden power failures
+
|This will protect you from sudden power failures.
  
 
|-
 
|-
| 06.06
+
| 06:05
 
|It will also be useful in case the applications were to crash.
 
|It will also be useful in case the applications were to crash.
  
 
|-
 
|-
| 06.11
+
| 06:10
|  Let  us now compile the program come back to a  terminal.
+
|  Let  us now compile the program, come back to a  terminal.
  
 
|-
 
|-
| 06.15
+
| 06:15
|Type '''“gcc”''' space '''“talk.c”''' space hyphen “-'''o”''' space '''“myoutput”'''
+
|Type '''“gcc”''' space '''“talk.c”''' space hyphen “-'''o”''' space '''“myoutput”''',
  
 
|-
 
|-
| 06.24
+
| 06:24
| '''gcc''' is the compiler
+
| '''gcc''' is the compiler,
  
 
|-
 
|-
| 06.27
+
| 06:27
 
|'''talk.c''' is our filename .
 
|'''talk.c''' is our filename .
 
|-
 
|-
| 06.30
+
| 06:30
|'''-o''' '''myoutput''' says that the executable should go to the file '''myoutput'''
+
|'''-o''' '''myoutput''' says that the executable should go to the file '''myoutput'''.
  
 
|-
 
|-
| 06.37
+
| 06:37
|  Now Press''' Enter. '''
+
|  Now Press''' Enter'''.
  
 
|-
 
|-
| 06.39
+
| 06:39
|We see that the program is compiled
+
|We see that the program is compiled.
  
 
|-
 
|-
| 06.42
+
| 06:42
|By typing '''ls -lrt''', we can see that '''myoutput''' is the last file to be created
+
|By typing '''ls space (hypen) -lrt''', we can see that '''myoutput''' is the last file to be created.
  
 
|-
 
|-
| 06.54
+
| 06:54
|To execute the program, type dot slash '''“./myoutput” ''' press '''Enter.'''
+
|To execute the program, type (dot slash)'''“./myoutput” ''', press '''Enter.'''
  
 
|-
 
|-
|07.01
+
|07:01
 
|  Here the output is displayed as '''“Talk To a Teacher”.'''
 
|  Here the output is displayed as '''“Talk To a Teacher”.'''
  
 
|-
 
|-
| 07.06
+
| 07:06
|  As I said before, return is the last statement to be executed
+
|  As I said before, return is the last statement to be executed.
  
 
|-
 
|-
| 07.10
+
| 07:10
|Thus after the return statement nothing will be executed. Let us try it out.
+
|Thus, after the return statement nothing will be executed. Let us try it out.
  
 
|-
 
|-
|07.16
+
|07:15
 
| come back to our program.
 
| come back to our program.
  
 
|-
 
|-
| 07.17
+
| 07:17
| After the '''return''' statement, let us include one more printf statement type printf("Welcome \n");
+
| After the '''return''' statement, let us include one more '''printf''' statement,
  
 
|-
 
|-
| 07.35
+
| 07:22
 +
| give space here, type printf opening bracket, closing bracket.  
 +
 
 +
|-
 +
| 07:27
 +
| Inside the bracket within the double quotes type Welcome backslash n ,  at the end type a semicolon.
 +
|-
 +
| 07:35
 
| Now click on  save.
 
| Now click on  save.
  
 
|-
 
|-
| 07.37
+
| 07:37
 
|Let us compile  and execute come back to our terminal.
 
|Let us compile  and execute come back to our terminal.
  
 
|-
 
|-
|07.41  
+
|07:41  
 
|  you can recall the previously entered commands by using '''up arrow'''key.
 
|  you can recall the previously entered commands by using '''up arrow'''key.
  
 
|-
 
|-
| 07.46
+
| 07:46
|That is what I did now
+
|That is what I did now.
  
 
|-
 
|-
| 07.51
+
| 07:51
|We see that the second  statements '''welcome''' is  not executed
+
|We see that the second  statement '''welcome''' is  not executed.
  
 
|-
 
|-
| 07.58
+
| 07:58
| Now come back to our program
+
| Now come back to our program.
  
 
|-
 
|-
| 08.00
+
| 08:00
|Let us write the 'Welcome' statement above the return statement
+
|Let us write the 'Welcome' statement above the return statement.
  
 
|-
 
|-
| 08.07
+
| 08:06
|  Click on Save.
+
|  Click on ''' Save.'''
  
 
|-
 
|-
| 08.09
+
| 08:09
|Let us compile and execute
+
|Let us compile and execute.
  
 
|-
 
|-
| 08.15
+
| 08:15
|We see that the second '''printf''' statement ''welcome'' has also has been executed
+
|We see that the second '''printf''' statement ''welcome'' has also been executed.
  
 
|-
 
|-
| 08.23
+
| 08:23
 
| Now let us see the common errors which we can come across.  Come back to our program.
 
| Now let us see the common errors which we can come across.  Come back to our program.
 
  
 
|-
 
|-
| 08.29  
+
| 08:29  
| Suppose here I  will the miss the dot in '''“stdio.h”''' Click on save.
+
| Suppose here I  will miss the dot in '''“stdio.h”''', click on '''Save.'''
 
+
  
 
|-
 
|-
| 08.35
+
| 08:36
 
| Let us  compile and execute .
 
| Let us  compile and execute .
  
 
|-
 
|-
| 08.42
+
| 08:41
|We see that
+
|We see that there is a fatal error  at line no.2 in our '''talk.c''' file.
  
 
|-
 
|-
| 08.43
+
| 08:48
|There is a fatal error  at line no.2 in our '''talk.c''' file.
+
|The compiler cannot find a '''header file''' with the name '''“stdioh”'''. Hence it is giving an error "no such file or directory".
  
 
|-
 
|-
| 08.48
+
| 08:59
|The compiler cannot find a '''header file''' with the name '''“stdioh”'''hence it is giving an error no such file or directory.
+
 
+
|-
+
| 08.59
+
 
|And the compilation is terminated.  
 
|And the compilation is terminated.  
 
|-
 
|-
| 09.03
+
| 09:03
|Let us  now fix the error come back to a   program Reinsert the dot '''“.”'''click on save
+
|Let us  now fix the error come back to a program. Reinsert the dot '''“.”''', click on Save.
 
+
  
 
|-
 
|-
| 09.11
+
| 09:11
| Let us compile and  execute it.Yes It is working.
+
| Let us compile and  execute. Yes, it is working.
  
 
|-
 
|-
| 09.19
+
| 09:19
| I will show you another common error
+
| I will show you another common error.
  
 
|-
 
|-
|09.23
+
|09:22
 
|Let us switch back to the program.
 
|Let us switch back to the program.
 
  
 
|-
 
|-
| 09.26
+
| 09:25
| Now, suppose here i will miss the '''semicolon'''  at the end of the line  
+
| Now, suppose here I will miss the '''semicolon'''  at the end of the line.
  
 
|-
 
|-
| 09.31
+
| 09:31
| Click on  '''Save'''.Let us compile and execute
+
| Click on  '''Save'''. Let us compile and execute.
  
 
|-
 
|-
| 09.42
+
| 09:41
| We see that there is  an error at line no.6 in our talk.c file. That expected ''semicolon'' before  printf.
+
| We see that there is  an error at line no.6 in our talk.c file. that "expected ';' (semicolon) before 'printf'".
 
|-
 
|-
| 09.51
+
| 09:51
|Come back to our program.  As  i said before semicolon acts as a statement terminator
+
|Come back to our program.   
  
 +
|-
 +
| 09:54
 +
|As I said before, semicolon acts as a statement terminator.
  
 
|-
 
|-
| 09.59
+
| 09:58
 
|So it will search for it at the end of the line.5 and at the beginning of the  line.6.  
 
|So it will search for it at the end of the line.5 and at the beginning of the  line.6.  
  
 
|-
 
|-
| 10.07
+
| 10:06
|  This is line 6
+
|  This is line 6.
  
 
|-
 
|-
| 10.09
+
| 10:09
|  This is the last place where you can put the '''semicolon'''
+
|  This is the last place where you can put the '''semicolon'''.
  
 
|-
 
|-
| 10.13
+
| 10:12
|Recall that the compiler also give the error message on line 6.
+
|Recall that the compiler also gives the error message on line 6.
  
 
|-
 
|-
| 10.18
+
| 10:18
 
| Let us try what happens if we put the semicolon here.
 
| Let us try what happens if we put the semicolon here.
  
 
|-
 
|-
| 10.24
+
| 10:23
 
| Click on '''Save''' .
 
| Click on '''Save''' .
  
 
|-
 
|-
| 10.26
+
| 10:26
|Let us   Compile and execute.Yes it is working
+
|Let us Compile and execute.
  
 
|-
 
|-
| 10.33
+
| 10:30
|Now come back to our program. Let us type the ''semicolon'' here  at the end of this line.
+
|Yes, it is working.  
 
+
 
+
  
 +
|-
 +
| 10:32
 +
|Now come back to our program. Let us type the ''semicolon'' here at the end of this line
  
 
|-
 
|-
| 10.41
+
| 10:40
| As it is a conventional practice to type  the ''semicolon'' at the end of the line. Now click on save.  
+
| as it is a conventional practice to type  the ''semicolon'' at the end of the line.
 +
|-
 +
| 10:46
 +
| Now click on '''Save.'''
  
 
|-
 
|-
| 10.49
+
| 10:49
|   Let us   Compile and execute. .Yes it is working.
+
| Let us Compile and execute. Yes it is working.
 
+
  
 
|-
 
|-
| 10.49
+
| 10:54
|Let us go back to our slides.  
+
|Now let us go back to our slides.  
  
 
|-
 
|-
|10.57
+
|10:57
 
| As an Assignment  
 
| As an Assignment  
  
 
|-
 
|-
| 10.59
+
| 10:59
 
|Write a program to print "Welcome to the World of C"
 
|Write a program to print "Welcome to the World of C"
  
 
|-
 
|-
| 11.03
+
| 11:02
 
|See what happens if  '''“\n”''' is not included in the '''printf''' statement.
 
|See what happens if  '''“\n”''' is not included in the '''printf''' statement.
  
 
|-
 
|-
| 11.09
+
| 11:08
| This brings us to the end of this tutorial  
+
| This brings us to the end of this tutorial.
  
 
|-
 
|-
| 11.12
+
| 11:12
| Watch the video available at the link shown http://spokentutorial.org/What\_is\_a\_Spoken\_Tutorial
+
| Watch the video available at the link shown below,
  
 
|-
 
|-
| 11.15
+
| 11:15
|It summarises the Spoken Tutorial project  
+
|It summarises the Spoken Tutorial project.
  
 
|-
 
|-
| 11.18
+
| 11:18
 
|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.
  
 
|-
 
|-
| 11.22
+
| 11:22
 
| The Spoken Tutorial Project Team  
 
| The Spoken Tutorial Project Team  
  
 
|-
 
|-
| 11.25
+
| 11:24
|Conducts workshops using spoken tutorials  
+
|Conducts workshops using spoken tutorials.
  
 
|-
 
|-
| 11.28
+
| 11:28
|Gives certificates to those who pass an online test  
+
|Gives certificates to those who pass an online test.
  
 
|-
 
|-
| 11.32
+
| 11:31
 
|For more details, please write to contact [at] spoken hyphen tutorial dot org
 
|For more details, please write to contact [at] spoken hyphen tutorial dot org
  
 
|-
 
|-
|11.38
+
|11:38
| 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.
  
 
|-
 
|-
| 11.42
+
| 11:42
|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.
  
 
|-
 
|-
| 11.48
+
| 11:47
|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:  
  
 
|-
 
|-
| 11.51
+
| 11:51
| This is Ashwini Patil from IIT Bombay. Thank you for joining.  
+
| This is Ashwini Patil from IIT Bombay signing off. Thank you for watching.  
  
 
|}
 
|}

Latest revision as of 16:32, 7 March 2017

Time Narration
00:01 Welcome to the spoken tutorial on First C program.
00:05 In this tutorial, we will learn
00:08 How to write a simple C program
00:11 How to compile it
00:13 How to execute it We will also explain some common errors and their solutions.
00:18 To record this tutorial, I am using
00:21 Ubuntu operating system version 11.10 and gcc Compiler version 4.6.1 on Ubuntu.
00:31 To practice this tutorial,
00:33 You should be familiar with Ubuntu Operating System and an Editor.
00:38 Some editors are vim and gedit.
00:42 I will use 'gedit' in this tutorial.
00:45 For relevant tutorials please visit our website which is as shown. http://spoken-tutorial.org
00:51 Let me tell you how to write a C program through an example.
00:55 Open the terminal window by pressing Ctrl, Alt and T keys simultaneously on your keyboard.
01:07 Now let's open the text editor. So, at the prompt, type
01:12 “gedit” space “talk” dot “c” space “&” sign.
01:20 We use ampersand (&) to free up the prompt.
01:24 Please note that all the C files will have extension “.c”(dot C).
01:30 Now Press Enter,
01:32 the text editor has opened.
01:36 Let us start to write a program.
01:39 Type double slash “//” space
01:42 “My first C program”.
01:48 Here, double slash is used to comment the line.
01:52 Comments are used to understand the flow of program.
01:56 It is useful for documentation.
01:58 It gives us information about the program.
02:01 The double slash is called as single line comment.
02:07 Now press Enter.
02:09 Type (hash) “#include” space opening bracket , closing bracket.
02:17 It is always a good practice to complete the brackets first, and then start writing inside it.
02:24 Now Inside the bracket, type“stdio” “(dot).” “h” .
02:30 stdio.h is a header file.
02:33 A program must contain this header file when it uses standard input/output functions.
02:41 Now press Enter.
02:43 type “int” space “main” opening bracket, closing bracket.
02:50 main is a special function.
02:52 It denotes that the execution of the program begins from this line.
02:58 The opening bracket and closing bracket is called as parenthesis.
03:04 Parenthesis followed by main is to tell the user that main is a function.
03:11 Here the int main function takes no arguments.
03:15 It returns a value of type integer.
03:18 We will learn about data types in another tutorial.
03:23 Now Let us switch to the slides to know more about main function. Let us go to the next slide.
03:29 Every program should have one main() function.
03:33 There should NOT be more than one main function.
03:36 Otherwise the compiler cannot locate the beginning of the program.
03:41 The empty pair of parentheses indicates that main has no arguments.
03:46 The concept of arguments will be discussed in detail in the upcoming tutorials.
03:52 Now let us come back to our program.
03:55 Press Enter.
03:58 Type opening curly bracket “{”.
04:00 The opening curly bracket marks the beginning of the function main.
04:04 Then Type closing curly bracket “}”.
04:08 The closing curly bracket indicates the end of the function main.
04:13 Now Inside the bracket press Enter twice,
04:16 move the cursor one line up.
04:20 Indentation makes the code easier to read.
04:23 It also helps to locate errors faster.
04:25 So let us give three space here
04:29 And Type “printf” opening bracket closing bracket “()” .
04:34 printf is a standard C function to print the output on the terminal.
04:39 Here, inside the brackets, within the double quotes.
04:43 Anything within the double quotes, in the printf statement, will be printed on the terminal.
04:50 Type“Talk To a Teacher backslash n”.
04:59 Backslash n “\n” signifies newline.
05:03 As a result, after execution of the printf function, the cursor moves to the new line.
05:10 Every C statement must end with a semicolon “;”.
05:15 Hence, type it at the end of this line.
05:19 Semicolon acts as a statement terminator.
05:24 Now press Enter give three space here.
05:27 And type “return” space “0” and a semicolon.
05:34 This statement returns the integer zero.
05:38 An integer has to be returned for this function because the function type is int.
05:45 The return statement marks the end of executable statements.
05:51 We will learn more about the returned values in another tutorial.
05:55 Now click on"Save" button to save the file.
06:00 It is a good habit to save files frequently.
06:03 This will protect you from sudden power failures.
06:05 It will also be useful in case the applications were to crash.
06:10 Let us now compile the program, come back to a terminal.
06:15 Type “gcc” space “talk.c” space hyphen “-o” space “myoutput”,
06:24 gcc is the compiler,
06:27 talk.c is our filename .
06:30 -o myoutput says that the executable should go to the file myoutput.
06:37 Now Press Enter.
06:39 We see that the program is compiled.
06:42 By typing ls space (hypen) -lrt, we can see that myoutput is the last file to be created.
06:54 To execute the program, type (dot slash)“./myoutput” , press Enter.
07:01 Here the output is displayed as “Talk To a Teacher”.
07:06 As I said before, return is the last statement to be executed.
07:10 Thus, after the return statement nothing will be executed. Let us try it out.
07:15 come back to our program.
07:17 After the return statement, let us include one more printf statement,
07:22 give space here, type printf opening bracket, closing bracket.
07:27 Inside the bracket within the double quotes type Welcome backslash n , at the end type a semicolon.
07:35 Now click on save.
07:37 Let us compile and execute come back to our terminal.
07:41 you can recall the previously entered commands by using up arrowkey.
07:46 That is what I did now.
07:51 We see that the second statement welcome is not executed.
07:58 Now come back to our program.
08:00 Let us write the 'Welcome' statement above the return statement.
08:06 Click on Save.
08:09 Let us compile and execute.
08:15 We see that the second printf statement welcome has also been executed.
08:23 Now let us see the common errors which we can come across. Come back to our program.
08:29 Suppose here I will miss the dot in “stdio.h”, click on Save.
08:36 Let us compile and execute .
08:41 We see that there is a fatal error at line no.2 in our talk.c file.
08:48 The compiler cannot find a header file with the name “stdioh”. Hence it is giving an error "no such file or directory".
08:59 And the compilation is terminated.
09:03 Let us now fix the error come back to a program. Reinsert the dot “.”, click on Save.
09:11 Let us compile and execute. Yes, it is working.
09:19 I will show you another common error.
09:22 Let us switch back to the program.
09:25 Now, suppose here I will miss the semicolon at the end of the line.
09:31 Click on Save. Let us compile and execute.
09:41 We see that there is an error at line no.6 in our talk.c file. that "expected ';' (semicolon) before 'printf'".
09:51 Come back to our program.
09:54 As I said before, semicolon acts as a statement terminator.
09:58 So it will search for it at the end of the line.5 and at the beginning of the line.6.
10:06 This is line 6.
10:09 This is the last place where you can put the semicolon.
10:12 Recall that the compiler also gives the error message on line 6.
10:18 Let us try what happens if we put the semicolon here.
10:23 Click on Save .
10:26 Let us Compile and execute.
10:30 Yes, it is working.
10:32 Now come back to our program. Let us type the semicolon here at the end of this line
10:40 as it is a conventional practice to type the semicolon at the end of the line.
10:46 Now click on Save.
10:49 Let us Compile and execute. Yes it is working.
10:54 Now let us go back to our slides.
10:57 As an Assignment
10:59 Write a program to print "Welcome to the World of C"
11:02 See what happens if “\n” is not included in the printf statement.
11:08 This brings us to the end of this tutorial.
11:12 Watch the video available at the link shown below,
11:15 It summarises the Spoken Tutorial project.
11:18 If you do not have good bandwidth, you can download and watch it.
11:22 The Spoken Tutorial Project Team
11:24 Conducts workshops using spoken tutorials.
11:28 Gives certificates to those who pass an online test.
11:31 For more details, please write to contact [at] spoken hyphen tutorial dot org
11:38 Spoken Tutorial Project is a part of the Talk to a Teacher project.
11:42 It is supported by the National Mission on Education through ICT, MHRD, Government of India.
11:47 More information on this Mission is available at the link shown below:
11:51 This is Ashwini Patil from IIT Bombay signing off. Thank you for watching.