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

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with ''''Title of script:''' First C program '''Author:''' Ashwini Patil '''Keywords: C Program, stdio.h, printf(), int main(), Video Tutorial''' {| style="border-spacing:0;" ! Vi…')
 
 
(20 intermediate revisions by 2 users not shown)
Line 3: Line 3:
 
'''Author:''' Ashwini Patil
 
'''Author:''' Ashwini Patil
  
'''Keywords: C Program, stdio.h, printf(), int main(), Video Tutorial'''
+
'''Keywords: C Program, printf(), int main(), Video Tutorial'''
  
  
  
 
{| style="border-spacing:0;"
 
{| style="border-spacing:0;"
! Visual Cue
+
| style="border-top:0.002cm solid #000000;border-bottom:0.002cm solid #000000;border-left:0.002cm solid #000000;border-right:none;padding:0.097cm;"| <center>'''Visual Cue'''</center>
! Narration
+
| style="border:0.002cm solid #000000;padding:0.097cm;"| <center>'''Narration'''</center>
 +
 
  
 
|-
 
|-
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 1
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0cm;"| Slide 1  
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Welcome to the spoken tutorial on First C program.  
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| Welcome to the spoken tutorial on First C program.  
  
 
|-
 
|-
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 2  
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0cm;"| Slide 2  
  
 
Learning Objectives  
 
Learning Objectives  
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| In this tutorial you will learn
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| In this tutorial we will learn,
  
To write a simple C program  
+
How to write a simple C program  
  
To compile it
+
How to compile it  
  
To execute it
+
How to execute it  
  
We will also explain some common errors and their solutions.  
+
We will also explain some common errors and their solution.  
  
 
|-
 
|-
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 3
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0cm;"| Slide 3  
  
 
System Requirements  
 
System Requirements  
Line 36: Line 37:
  
  
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| To record this tutorial, I am using
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| To record this tutorial, I am using  
  
Ubuntu operating system version 11.10
+
Ubuntu operating system version 11.10  
  
and gcc Compiler 4.6.1 on Ubuntu
+
and GCC Compiler version 4.6.1 on Ubuntu.
  
 
|-
 
|-
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 4
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0cm;"| Slide 4  
  
 
Prerequisites  
 
Prerequisites  
Line 49: Line 50:
  
  
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| To practice this tutorial,  
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| To practice this tutorial,  
  
You should be familiar with Ubuntu Operating System
+
You should be familiar with Ubuntu Operating System.
  
an Editor
+
And an editor.
  
Some editors are vim and gedit
+
Some editors are vim and gedit  
  
I will use gedit in this tutorial
+
I will use gedit in this tutorial.
  
For relevant tutorials please visit our website:
+
For relevant tutorials please visit our website which is as shown:  
  
 
[http://spoken-tutorial.org/ http://spoken-tutorial.org]  
 
[http://spoken-tutorial.org/ http://spoken-tutorial.org]  
  
 
|-
 
|-
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Open the terminal
+
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| /*Switch to Terminal*/
  
Open the terminal using '''Ctrl + Alt + T '''simultaneously
+
Open the terminal using Ctrl + Alt + T or alternately,
  
 +
Click on Applications-> Accessories -> Terminal
  
 +
At the command prompt type: gedit firstprog.c
  
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Let me tell you how to write a C program through an example
+
Type:  
  
Open the terminal by pressing '''Ctrl, Alt and T '''keys simultaneously
+
'''//My first C program'''  
  
  
  
 +
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| Let me tell you how to write a C program through an example
  
|-
+
Open the terminal Window by pressing '''Ctrl, Alt '''and '''T''' keys Simultaneously on your keyboard.
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| At the command prompt type:
+
  
 +
Now lets open the text editor, So at the prompt type:
  
'''gedit talk.c &'''
+
'''"gedit"''' space '''"talk"''' dot '''"c"''' space '''&'''(ampersand sign)
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Now let's open the text editor. So, at the prompt, type
+
  
'''“gedit”''' space '''“talk”''' dot '''“c”''' space <nowiki>[</nowiki>ampersand]''' &'''
+
We used the ampersand'''(&)''' to free up the prompt
  
'''We use ampersand (&) to free up the prompt '''
+
Please note that all the '''C''' files will have extension dot '''"c"'''  
  
|-
+
Now Press '''Enter. '''
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Highlight the .c extension
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Please note that all the '''C''' files have the extension dot '''“c”'''
+
  
|-
+
The text editor has opened.  
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"|
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Now Press '''Enter'''
+
  
|-
+
Let us start to write a program.  
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"|
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Now the text editor has opened
+
  
|-
+
Type double slash '''//”''' space  
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"|
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Let us write a program
+
 
+
|-
+
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"|
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Type double slash '''//”''' space  
+
  
'''“My first C program”.'''
+
'''My first C program”.'''  
  
 
|-
 
|-
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"|  
+
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| '''//My first C program'''
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Here, double slash is used to comment the line
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| Here, double slash is used to comment the line.
  
Comments are used to understand the flow of program
+
Comments are used to understand the flow of program.
  
It is useful for documentation
+
It is useful for documentation.
  
It gives us information about the program
+
It gives us information about the program.
  
The double slash is called as single line comment.
+
The double slash is called as '''single line comment.'''
  
 
|-
 
|-
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"|
+
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| Highlight '''//'''  
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Now press '''Enter'''
+
  
|-
+
'''<nowiki>#include <stdio.h> </nowiki>'''
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| '''Type'''
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| Now press '''Enter'''  
  
'''<nowiki>#include <></nowiki>'''
+
Type "hash '''(#)''' '''include''' (space) opening bracket, closing bracket.
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Type hash '''“#include”''' space opening angle bracket '''<nowiki>“<”</nowiki>''', closing angle bracket''' “>”'''
+
  
|-
+
It is always a good practice to complete the brackets first, and then start writing inside it.
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"|
+
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| It is always a good practice to complete the brackets first, and then start writing inside it
+
  
|-
+
Now, Inside the bracket, type:  
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| '''Type'''
+
  
'''<nowiki>#include <stdio.h></nowiki>'''
+
'''"stdio"''' dot '''"h" '''
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Inside the bracket, type
+
  
'''“stdio”''' dot”.” “'''h” '''
+
'''stdio.h''' is a '''header file'''  
  
|-
+
A program must contain this header file when it uses standard input/output functions
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Highlight stdio.h
+
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| '''stdio.h''' is a '''header file'''
+
  
A p'''rogram''' must contain this header file when it uses standard '''input/output functions'''.
+
Now press '''Enter '''
  
 
|-
 
|-
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Move cursor to the end of the line.
+
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| <nowiki>#include<stdio.h> </nowiki>
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Move the cursor to the end of the line
+
  
and press''' Enter '''.
+
int main()
  
|-
 
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Type
 
  
'''int main()'''
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Then type '''“int” '''space''' “main” '''opening bracket and closing bracket '''“()”. '''
 
  
|-
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| Type: "'''int''' (space) '''main()'''" (opening bracket and closing bracket)
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Highlight main
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| '''Function''' '''main''' is a special '''function''' used by C
+
  
It denotes that the execution of the program begins from this line
+
'''main()''' is a special function.
  
The opening bracket and the closing bracket is called as parenthesis.
+
It denotes that the execution of the program begins from this line.  
  
|-
+
The opening bracket and closing bracket is called as paranthesis.  
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Highlight ()
+
  
 +
Paranthesis followed by '''main()''' is to tell the user that main is a function.
  
 +
Here the '''int main()''' function takes no arguments. It returns a value of type integer.
  
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Parenthesis followed by '''main''' is to tell the user that '''main''' is a '''function'''
+
We will learn about data types in another tutorial.  
  
|-
+
Now let us switch to the slides to know more about the '''main()''' function.
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Highlight int main()
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Here the '''int''' '''main function''' takes no '''arguments'''
+
  
It returns a value of type '''integer'''.
+
Let us go tot he next slide.  
  
 
|-
 
|-
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"|  
+
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| Slide 5
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| We will learn about '''data types''' in another tutorial.
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| Every program should have one '''main''' function.  
  
|-
+
There should NOT be more than one main function.  
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Switch to the slides
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Let us switch to the slides to know more about the '''main function'''.
+
  
|-
+
Otherwise, the compiler cannot locate the beginning of the program.  
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Slide 5
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Every '''program''' will have only one main function
+
  
There should NOT be more than one main function
+
The empty pair of parentheses indicate that main has no arguments.
  
Otherwise the compiler cannot locate the beginning of the program
+
The concept of arguments will be discussed in detail in the upcoming tutorials.
  
The empty pair of parentheses indicates that main has no '''arguments'''
+
|-
 +
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| <nowiki>#include<stdio.h> </nowiki>
  
The concept of arguments will be discussed in detail in the upcoming tutorials.
+
int main()
  
|-
+
{
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Switch to the editor
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Now let us go back to our program.
+
  
|-
 
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Type
 
  
'''{ '''
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Type the opening curly brace '''“{”'''
 
  
The opening curly bracket marks the beginning of the '''function''' '''main'''.
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| Now let us come back to our program,
  
|-
+
Press '''Enter'''
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Type
+
  
'''}'''
+
type: '''{''' (opening curly bracket)
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Type the closing brace '''“}”'''
+
  
The closing curly bracket indicates the end of the '''function''' '''main'''.
+
The opening curly bracket marks the beginning of the function '''main. '''
  
 
|-
 
|-
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Press Enter twice within the braces
+
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| <nowiki>#include<stdio.h> </nowiki>
  
Move the cursor one line up
+
int main()
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Inside the braces
+
  
press '''Enter''' twice, and then move the cursor one line up
+
{
  
|-
+
}
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Give a space
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| Then
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Indentation makes the code easier to read
+
  
It also helps to locate errors faster
+
Type: '''}''' (Closing curly bracket)
  
So let us give three space here
+
The Closing bracket indicates the end of the function '''main.'''
  
 
|-
 
|-
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Type
+
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"|  
 
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| Now inside the bracket  
'''printf()'''
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Type''' “printf” '''and opening bracket and closing bracket '''“()” '''
+
  
'''printf '''is a standard C function to print the output on the terminal
+
press enter twice, move the cursor one line up
  
 
|-
 
|-
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| '''Highlight the text in the double quotes'''
+
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"|  
 +
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| Indentation makes the code easier to read
  
 +
It also helps to locate errors faster
  
'''printf("Talk To a Teacher\n");'''
+
So let us give three space here.  
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Here inside the brackets, type
+
  
within double quotes,
+
|-
 +
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| <nowiki>#include<stdio.h> </nowiki>
  
Anything within the double quotes in the printf statement will be pritned on the terminal.
+
int main()
  
Type
+
{
  
'''“Talk To a Teacher '''backslash '''n”'''
+
printf("Talk To a Teacher \n");
  
|-
 
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Highlight \n
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Backslash n '''“\n” '''signifies newline
 
  
As a result, after execution of the '''printf '''function,
 
  
the cursor moves to a new line
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| And Type:
  
|-
+
'''printf''' opening bracket closing bracket '''()'''  
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Type semicolon (;)
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Every '''C''' statement must end with a '''semicolon “;”'''
+
  
Hence, type it at the end of this line.  
+
'''printf()''' is a standard '''C''' function to print the output on the terminal.  
  
'''Semicolon''' acts as a statement terminator.
+
Here inside the brackets, within double quotes,
  
|-
+
Anything within the double quotes in the '''printf''' statement will be printed on the terminal.
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"|
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Now press '''Enter'''
+
  
give three space here
+
Type:
  
|-
+
'''Talk To a Teacher''' backward slash '''(\)''' and '''"n"'''  
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Type '''return 0;'''
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Now type '''“return”''' space''' “0”''' and a '''semicolon''' '''“;”'''
+
  
|-
+
'''\n''' (BackSlash n) signifies newline,
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"|
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| This statement returns the integer zero
+
  
An integer has to be returned for this function
+
As a result after the execution of the printf function the cursor moves to the new line.
  
because the function type is '''int'''
+
Every '''C''' statement must end with a semicolon'''(;)'''  
  
The '''return''' statement marks the end of executable statements
+
Hence Type it at the end of this line.
  
We will learn more about the returned values in another tutorial.
+
Semicolon'''(;)''' acts as a statement terminator.  
  
 
|-
 
|-
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Click on Save
+
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| <nowiki>#include<stdio.h> </nowiki>
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Now click on the "'''Save'''" button to save the file
+
  
It is a good habit to save files frequently
+
int main()
  
This will protect you from sudden power failures
+
{
  
It will also be useful in case the applications were to crash.
+
printf("Talk To a Teacher \n");
  
|-
+
return 0;  
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Type
+
  
'''gcc talk.c -o myoutput'''
+
}
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Let us now compile the program
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| Now press '''Enter'''
  
Please open the terminal
+
Give three space here.
  
Type '''“gcc”''' space '''“talk.c”''' space hyphen “-'''o”''' space '''“myoutput”'''
+
And type ''''return''' (space)'''0'''' and a semicolon ''''<nowiki>;'</nowiki>'''  
  
|-
+
This statement returns the integer zero.  
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Highlight or point to each component of the statement
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| '''gcc''' is the compiler
+
  
'''talk.c''' is the filename
+
An integer has to be returned for this function.  
  
on compilation '''gcc''' creates an executable
+
Because the function type is int.
  
'''-o''' '''myoutput''' says that the executable should go to the file '''myoutput'''
+
The return statement marks the end of the executable statements.
  
Press''' Enter. '''
+
We will learn more about the returned values in another tutorial.  
  
 
|-
 
|-
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Type '''ls -lrt'''
+
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| <nowiki>#include<stdio.h> </nowiki>
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| We see that the program is compiled
+
  
By typing '''ls -lrt''', we can see that '''myoutput''' is the last file to be created
+
int main()
  
 +
{
  
 +
printf("Talk To a Teacher \n");
  
 +
return 0;
  
|-
+
}
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Type '''./myoutput'''
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| To execute the program,
+
  
type dot slash '''“./myoutput” '''
+
'''Type:'''  
  
and press '''Enter.'''
+
'''gcc talk.c -o myoutput'''  
  
|-
+
'''Highlight'''  
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"|
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Here the output is displayed as '''“Talk To a Teacher”.'''
+
  
|-
+
'''gcc'''  
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Type '''return 0;'''
+
  
 +
'''talk.c'''
  
 +
'''-o myoutput'''
 +
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| Now Click on the '''"Save"''' button to save the file.
  
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| As I said before, return is the last statement to be executed
+
It is a good habit to save files frequently.
  
Thus after the return statement nothing will be executed
+
This will protect you from sudden power failures.
  
Let us try it out.
+
It will also be useful in case the applications were to crash.  
  
|-
+
Let us now compile the program  
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Switch to the editor
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Let us come back to our program.
+
  
|-
+
Come back to our terminal
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Type '''printf("Welcome \n"); '''
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| After the '''return''' statement, let us include one more printf statement
+
  
type printf("Welcome \n");
+
Type: '''"gcc"''' space “'''talk.c”''' space hyphen '''o''' space “'''myoutput"'''
  
|-
+
'''gcc''' is the compiler.  
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Click on Save icon.
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Now save it.
+
  
|-
+
'''talk.c''' is the filename.
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Type '''gcc talk.c -o myoutput'''
+
  
 +
'''-o''' '''myoutput''' says that the executable should go to the file myoutput.
  
Type '''./myoutput'''
+
Now press '''Enter'''  
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Let us compile and run the program as before
+
  
'''gcc talk.c -o myoutput'''
+
We see that the program is compiled.  
 
+
'''./myoutput.'''
+
  
 
|-
 
|-
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"|  
+
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| Type:
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| We see that the second statement ''''Welcome'''' is not executed.
+
 
 +
'''ls -lrt'''
 +
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| By typing '''ls -lrt''', we can see that '''myoutput''' is the last file to be created.  
  
 
|-
 
|-
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Press up arrow key
+
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| '''Type:'''  
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| On the terminal, you can recall the previously entered commands by using '''up arrow'''
+
  
That is what I did now
+
'''./myoutput'''
 +
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| To execute the program,
  
We see that the statements after '''return''' are not executed
+
type '''./myoutput''' (dot slash "myoutput")
  
|-
+
press '''Enter '''
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Shift '''printf("Welcome \n"); '''
+
  
above '''return 0;'''
+
Here the output is displayed as: "Talk To a Teacher".  
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Now come back to our program
+
 
+
Let us write the 'Welcome' statement above the return statement
+
  
 
|-
 
|-
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Click on Save
+
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"|  
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Save it
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| As I said before, return is the last statement to be executed.
  
|-
+
Thus after the return statement nothing will be executed.  
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| On the terminal, use up arrow to get “gcc talk.c -o myoutput”
+
  
and press Enter.
+
Let us try it out.
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Let us compile and execute
+
  
We see that the second '''printf''' statement also has been executed
+
Come back to our program.
  
 
|-
 
|-
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| '''Errors'''
+
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"|  
 +
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| After the return statement let us include one more printf statment.
  
 +
Give space here.
  
 +
'''printf''' opening bracket closing bracket '''()'''
  
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Now let us see the common errors which we can come across
+
inside the brackets, within double quotes,
  
Let's switch to the editor
+
type: “'''Welcome”''' backslash '''n'''
 +
 
 +
At the end type a semicolon '''<nowiki>;</nowiki>'''
  
 
|-
 
|-
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Type
+
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"|
 +
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| Click on '''Save'''
  
 +
Let us compile and execute.
  
'''<nowiki><stdio.h></nowiki>'''
+
Come back to our terminal.  
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Suppose we miss the dot '''“.”''' in
+
  
'''<nowiki><stdio.h></nowiki>'''
+
You can recall the previously entered command by using up arrow key.  
  
I will retain rest of the code as it is
+
That is what I did now.
 +
 
 +
We see that the second statement '''Welcome''' is not executed.
  
 
|-
 
|-
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Click on '''Save'''
+
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"|  
 +
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| Now come back to our program.
  
Switch to the terminal
+
Let us write the Welcome statement above the return statement.
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| save the program
+
 
+
Let us go to the terminal
+
  
 
|-
 
|-
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| On the terminal, use up arrow to get “gcc talk.c -o myoutput”
+
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"|  
 +
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| Click on Save
  
and press '''Enter'''.
+
Let us compile and execute.  
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Now compile the program using the command we used before
+
  
We see that
+
|-
 +
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"|
 +
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| We see that the second printf statement Welcome has also been executed.
  
There is a fatal error in our '''talk.c''' file at line no.1 and column no.18
+
|-
 +
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| Errors
  
The compiler cannot find a '''header file''' with the name '''“stdioh”'''
+
Type:
  
hence the compilation is terminated.
+
<nowiki><stdioh> </nowiki>
 +
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| Now,let us see the common errors which we can come across
  
|-
+
Come back to our program.  
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Reinsert the dot “.”
+
  
 +
Now suppose here I will miss the dot ''''.'''' in
  
 +
'''<nowiki><stdio.h></nowiki>'''
  
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Let us fix the error we made on the header file
+
Click on '''Save '''
  
Reinsert the dot '''“.”'''
+
Let us compile and execute.  
  
 +
we see that there is an 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" and the compilation is terminated.
  
 
|-
 
|-
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Click on Save
+
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"|  
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Save it
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| Let us now fix the error.
  
|-
+
Come back to our program.  
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| On the terminal, use up arrow to get “gcc talk.c -o myoutput” and press Enter.
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Let us now execute it
+
  
It is working.
+
Reinsert the “'''.”'''
  
 
|-
 
|-
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Switch back to gedit
+
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"|
 +
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| '''Click on Save'''
  
 +
Let us compile and execute.
  
 +
Yes it is working.
  
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| I will show you another common error
+
|-
 +
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| Error 2
  
Let us switch back to the editor
+
Type:
  
 +
printf("Hello World \n")
  
  
  
|-
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| I will show you another common error.
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Type:
+
  
'''printf("Talk To a Teacher\n")'''
+
Let us switch back to the program.  
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Now, suppose that we miss the '''semicolo'''n at the end of '''printf() '''statement.
+
  
|-
+
Now, suppose here I will miss the semicolon at the end of the line.  
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Click on Save
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| '''Save''' it
+
  
Switch to the terminal.
+
Click on '''Save'''
  
|-
+
Let us compile and execute.  
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Type '''clear '''and press Enter
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| I will clear the terminal by typing
+
  
'''“clear”''' command.
+
we see that there is an error at line no.6 in our '''talk.c''' file.  
  
|-
+
That expected semicolon before '''printf.'''
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| On the terminal, use up arrow to get “gcc talk.c -o myoutput” and press Enter.
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Now compile the program
+
  
using command that we have used before.
+
Come back to our program.  
  
 +
As I said before, semicolon acts as a statement terminator.
  
And press '''Enter.'''
+
So it will search for it at the end of the line 5 and at the begning of the line 6.  
  
|-
+
This is line 6.  
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Point to line no. 5 and column no. 1 on the screen
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| we see an error message at line no.5 and column no.1 in talk.c file.
+
  
|-
+
This is the last place where you can put the semicolon.  
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"|
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| As i said before semicolon acts as a statement terminator
+
  
So it will search for it at the end of the line
+
Recall that compiler also gave the error message on line 6.  
 
+
and also at the beginning of the next line.  
+
  
 
|-
 
|-
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Bring the cursor to line 5
+
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"|  
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Now come back to our program
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| Let us try what happens if you put the semicolon here.
 
+
This is line 5
+
 
+
 
+
  
 +
Click on '''Save.'''
  
 
|-
 
|-
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Point to the location
+
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"|  
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| This is the last place where you can put the '''semicolon'''
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| Let us compile and execute.
  
Recall that the compiler also gives the error message on line 5.
+
Yes it is working.  
  
 
|-
 
|-
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Put the semicolon at the beginning of line 6
+
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"|  
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Let us try what happens if we put the semicolon in the next line.
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| Now come back to our program.  
  
|-
+
Let us type the semicolon here at the end of this line.  
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Click on Save
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| '''Save''' it
+
  
|-
+
As it is the conventional practice to type the semicolon at the end of the line.  
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| On the terminal, use up arrow to get “gcc talk.c -o myoutput” and press Enter.
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Compile it and execute it
+
  
 
|-
 
|-
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Back to the editor
+
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"|  
 +
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| Now click on '''Save.'''
  
Put semicolon back in original location
+
Let us compile and execute.
  
 +
Yes it is working.
  
 +
Now let us move back to our slides.
  
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Let us now fix the error
+
|-
 +
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| Slide 7
  
 +
Assignment
 +
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| As an Assignment
  
 +
Write a program to print '''"Welcome to the World of C" '''
  
 +
See what happens if \n is not included in the '''printf''' statement.
  
 
|-
 
|-
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Click on Save
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0cm;"|  
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Click on '''Save'''
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| This brings us to the end of this tutorial
  
 
|-
 
|-
| style="background-color:transparent;border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| On the terminal, use up arrow to get “gcc talk.c -o myoutput” and press Enter.
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0cm;"| Slide 8
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Now execute it
+
  
It is working
+
About the Spoken Tutorial Project
  
|-
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 7
 
  
Assignment
 
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| As an Assignment
 
  
Write a program to print "Welcome to the World of C"
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| Watch the video available at the link shown below
  
See what happens if we do not write '''“\n”''' in the '''printf''' statement.
+
[http://spoken-tutorial.org/ http://spoken-tutorial.org] /What\_is\_a\_Spoken\_Tutorial  
 
+
|-
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide 8
+
 
+
About the Spoken Tutorial Project
+
 
+
 
+
 
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Watch the video available at the link shown
+
 
+
http://spoken-tutorial.org /What\_is\_a\_Spoken\_Tutorial
+
  
 
It summarises the Spoken Tutorial project  
 
It summarises the Spoken Tutorial project  
  
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.  
  
 
|-
 
|-
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Slide Number 9
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0cm;"| Slide Number 9  
  
Spoken Tutorial Workshops
+
Spoken Tutorial Workshops  
  
  
  
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| The Spoken Tutorial Project Team  
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| The Spoken Tutorial Project Team  
  
 
Conducts workshops using spoken tutorials  
 
Conducts workshops using spoken tutorials  
Line 623: Line 545:
 
Gives certificates to those who pass an online test  
 
Gives certificates to those who pass an online test  
  
<nowiki>For more details, please write to contact [at] spoken hyphen tutorial dot org</nowiki>
+
For more details,please write to contact@spoken-tutorial.org  
  
 
|-
 
|-
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| lide Number 10
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0cm;"| Slide Number 10  
  
 +
Acknowledgement
 +
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| Spoken Tutorial Project is a part of the Talk to a Teacher project
  
Acknowledgement
+
It is supported by the National Mission on Education through ICT, MHRD, Government of India
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Spoken Tutorial Project is a part of the Talk to a Teacher project
+
  
It is supported by the National Mission on Education through ICT, MHRD, Government of India
+
More information on this Mission is available at the link shown below: http://spoken-tutorial.org\NMEICT-Intro  
 
+
More information on this Mission is available at: http://spoken-tutorial.org\NMEICT-Intro
+
  
 
|-
 
|-
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Remain on previous slide
+
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0cm;"| Slide Number 11
 
+
No slide for this part
+
 
+
 
+
  
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| This is Ashwini Patil from IIT Bombay.
+
About the contributor
 +
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding-top:0cm;padding-bottom:0.097cm;padding-left:0.097cm;padding-right:0.097cm;"| This is Ashwini Patil from IIT Bombay signing off
  
Thank you for joining.  
+
Thank You for joining.  
  
 
|}
 
|}

Latest revision as of 16:39, 14 July 2014

Title of script: First C program

Author: Ashwini Patil

Keywords: C Program, printf(), int main(), Video Tutorial


Visual Cue
Narration


Slide 1 Welcome to the spoken tutorial on First C program.
Slide 2

Learning Objectives

In this tutorial we will learn,

How to write a simple C program

How to compile it

How to execute it

We will also explain some common errors and their solution.

Slide 3

System Requirements


To record this tutorial, I am using

Ubuntu operating system version 11.10

and GCC Compiler version 4.6.1 on Ubuntu.

Slide 4

Prerequisites


To practice this tutorial,

You should be familiar with Ubuntu Operating System.

And an editor.

Some editors are vim and gedit

I will use gedit in this tutorial.

For relevant tutorials please visit our website which is as shown:

http://spoken-tutorial.org

/*Switch to Terminal*/

Open the terminal using Ctrl + Alt + T or alternately,

Click on Applications-> Accessories -> Terminal

At the command prompt type: gedit firstprog.c

Type:

//My first C program


Let me tell you how to write a C program through an example

Open the terminal Window by pressing Ctrl, Alt and T keys Simultaneously on your keyboard.

Now lets open the text editor, So at the prompt type:

"gedit" space "talk" dot "c" space &(ampersand sign)

We used the ampersand(&) to free up the prompt

Please note that all the C files will have extension dot "c"

Now Press Enter.

The text editor has opened.

Let us start to write a program.

Type double slash “//” space

My first C program”.

//My first C program Here, double slash is used to comment the line.

Comments are used to understand the flow of program.

It is useful for documentation.

It gives us information about the program.

The double slash is called as single line comment.

Highlight //

#include <stdio.h>

Now press Enter

Type "hash (#) include (space) opening bracket, closing bracket.

It is always a good practice to complete the brackets first, and then start writing inside it.

Now, Inside the bracket, type:

"stdio" dot "h"

stdio.h is a header file

A program must contain this header file when it uses standard input/output functions

Now press Enter

#include<stdio.h>

int main()


Type: "int (space) main()" (opening bracket and closing bracket)

main() is a special function.

It denotes that the execution of the program begins from this line.

The opening bracket and closing bracket is called as paranthesis.

Paranthesis followed by main() is to tell the user that main is a function.

Here the int main() function takes no arguments. It returns a value of type integer.

We will learn about data types in another tutorial.

Now let us switch to the slides to know more about the main() function.

Let us go tot he next slide.

Slide 5 Every program should have one main function.

There should NOT be more than one main function.

Otherwise, the compiler cannot locate the beginning of the program.

The empty pair of parentheses indicate that main has no arguments.

The concept of arguments will be discussed in detail in the upcoming tutorials.

#include<stdio.h>

int main()

{


Now let us come back to our program,

Press Enter

type: { (opening curly bracket)

The opening curly bracket marks the beginning of the function main.

#include<stdio.h>

int main()

{

}

Then

Type: } (Closing curly bracket)

The Closing bracket indicates the end of the function main.

Now inside the bracket

press enter twice, move the cursor one line up

Indentation makes the code easier to read

It also helps to locate errors faster

So let us give three space here.

#include<stdio.h>

int main()

{

printf("Talk To a Teacher \n");


And Type:

printf opening bracket closing bracket ()

printf() is a standard C function to print the output on the terminal.

Here inside the brackets, within double quotes,

Anything within the double quotes in the printf statement will be printed on the terminal.

Type:

Talk To a Teacher backward slash (\) and "n"

\n (BackSlash n) signifies newline,

As a result after the execution of the printf function the cursor moves to the new line.

Every C statement must end with a semicolon(;)

Hence Type it at the end of this line.

Semicolon(;) acts as a statement terminator.

#include<stdio.h>

int main()

{

printf("Talk To a Teacher \n");

return 0;

}

Now press Enter

Give three space here.

And type 'return (space)0' and a semicolon ';'

This statement returns the integer zero.

An integer has to be returned for this function.

Because the function type is int.

The return statement marks the end of the executable statements.

We will learn more about the returned values in another tutorial.

#include<stdio.h>

int main()

{

printf("Talk To a Teacher \n");

return 0;

}

Type:

gcc talk.c -o myoutput

Highlight

gcc

talk.c

-o myoutput

Now Click on the "Save" button to save the file.

It is a good habit to save files frequently.

This will protect you from sudden power failures.

It will also be useful in case the applications were to crash.

Let us now compile the program

Come back to our terminal

Type: "gcc" space “talk.c” space hyphen o space “myoutput"

gcc is the compiler.

talk.c is the filename.

-o myoutput says that the executable should go to the file myoutput.

Now press Enter

We see that the program is compiled.

Type:

ls -lrt

By typing ls -lrt, we can see that myoutput is the last file to be created.
Type:

./myoutput

To execute the program,

type ./myoutput (dot slash "myoutput")

press Enter

Here the output is displayed as: "Talk To a Teacher".

As I said before, return is the last statement to be executed.

Thus after the return statement nothing will be executed.

Let us try it out.

Come back to our program.

After the return statement let us include one more printf statment.

Give space here.

printf opening bracket closing bracket ()

inside the brackets, within double quotes,

type: “Welcome” backslash n

At the end type a semicolon ;

Click on Save

Let us compile and execute.

Come back to our terminal.

You can recall the previously entered command by using up arrow key.

That is what I did now.

We see that the second statement Welcome is not executed.

Now come back to our program.

Let us write the Welcome statement above the return statement.

Click on Save

Let us compile and execute.

We see that the second printf statement Welcome has also been executed.
Errors

Type:

<stdioh>

Now,let us see the common errors which we can come across

Come back to our program.

Now suppose here I will miss the dot '.' in

<stdio.h>

Click on Save

Let us compile and execute.

we see that there is an 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" and the compilation is terminated.

Let us now fix the error.

Come back to our program.

Reinsert the “.”

Click on Save

Let us compile and execute.

Yes it is working.

Error 2

Type:

printf("Hello World \n")


I will show you another common error.

Let us switch back to the program.

Now, suppose here I will miss the semicolon at the end of the line.

Click on Save

Let us compile and execute.

we see that there is an error at line no.6 in our talk.c file.

That expected semicolon before printf.

Come back to our program.

As I said before, semicolon acts as a statement terminator.

So it will search for it at the end of the line 5 and at the begning of the line 6.

This is line 6.

This is the last place where you can put the semicolon.

Recall that compiler also gave the error message on line 6.

Let us try what happens if you put the semicolon here.

Click on Save.

Let us compile and execute.

Yes it is working.

Now come back to our program.

Let us type the semicolon here at the end of this line.

As it is the conventional practice to type the semicolon at the end of the line.

Now click on Save.

Let us compile and execute.

Yes it is working.

Now let us move back to our slides.

Slide 7

Assignment

As an Assignment

Write a program to print "Welcome to the World of C"

See what happens if \n is not included in the printf statement.

This brings us to the end of this tutorial
Slide 8

About the Spoken Tutorial Project


Watch the video available at the link shown below

http://spoken-tutorial.org /What\_is\_a\_Spoken\_Tutorial

It summarises the Spoken Tutorial project

If you do not have good bandwidth, you can download and watch it.

Slide Number 9

Spoken Tutorial Workshops


The Spoken Tutorial Project Team

Conducts workshops using spoken tutorials

Gives certificates to those who pass an online test

For more details,please write to contact@spoken-tutorial.org

Slide Number 10

Acknowledgement

Spoken Tutorial Project is a part of the Talk to a Teacher project

It is supported by the National Mission on Education through ICT, MHRD, Government of India

More information on this Mission is available at the link shown below: http://spoken-tutorial.org\NMEICT-Intro

Slide Number 11

About the contributor

This is Ashwini Patil from IIT Bombay signing off

Thank You for joining.

Contributors and Content Editors

Ashwini, PoojaMoolya