Difference between revisions of "C-and-C++/C2/First-C++-Program/English"
PoojaMoolya (Talk | contribs) |
|||
(9 intermediate revisions by 2 users not shown) | |||
Line 3: | Line 3: | ||
'''Author:''' Ashwini | '''Author:''' Ashwini | ||
− | '''Keywords: int main(), ''' | + | '''Keywords: C++ Program, cout<<, cin>>, int main(), Video Tutorial ''' |
Line 55: | Line 55: | ||
and an Editor | and an Editor | ||
− | Some editors are vim | + | Some editors are vim and gedit. |
I am using gedit in this tutorial. | I am using gedit in this tutorial. | ||
− | For relevant tutorial Please visit our website: | + | For relevant tutorial Please visit our website which is as shown: |
[http://spoken-tutorial.org/ http://spoken-tutorial.org] | [http://spoken-tutorial.org/ http://spoken-tutorial.org] | ||
Line 76: | Line 76: | ||
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| To open the text editor, type on the terminal | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| To open the text editor, type on the terminal | ||
− | '''“gedit”''' space '''“talk”''' dot '''“.cpp”''' space ampersand '''“&” | + | '''“gedit”''' space '''“talk”''' dot '''“.cpp”''' space ampersand '''“&”''' sign |
|- | |- | ||
Line 132: | Line 132: | ||
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Here iostream is a header file | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Here iostream is a header file | ||
− | This file includes the declaration of | + | This file includes the declaration of standard input output functions in''' C++.''' |
|- | |- | ||
Line 176: | Line 176: | ||
|- | |- | ||
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Highlight '''()''' | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding: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;"| Parenthesis followed by '''main''' | + | | 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''' tells the user that '''main''' is a '''function.''' |
|- | |- | ||
Line 192: | Line 192: | ||
|- | |- | ||
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;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;"| Every program | + | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Every program should have one '''main''' function |
There should NOT be more than one '''“main”''' function | There should NOT be more than one '''“main”''' function | ||
Line 214: | Line 214: | ||
|- | |- | ||
| style="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: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:0.097cm;"| | + | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Then type closing curly bracket '''“}”''' |
The closing curly bracket indicates the end of the '''function main. ''' | The closing curly bracket indicates the end of the '''function main. ''' | ||
− | + | Now inside the bracket press enter twice | |
Move the cursor one line up. | Move the cursor one line up. | ||
Line 232: | Line 232: | ||
|- | |- | ||
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Type '''<nowiki>cout << </nowiki>''' | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Type '''<nowiki>cout << </nowiki>''' | ||
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| And type '''“cout”''' space two opening angle bracket '''<nowiki>“<<”</nowiki>''' | + | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| And type '''“cout”''' space two opening angle bracket '''<nowiki>“<<”</nowiki>''' |
|- | |- | ||
Line 254: | Line 254: | ||
|- | |- | ||
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| Highlight '''\n''' | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;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;"| '''\n''' signifies newline | + | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"|Here '''\n''' signifies newline |
As a result, after execution of the '''cout function''', the cursor moves to the new line. | As a result, after execution of the '''cout function''', the cursor moves to the new line. | ||
Line 275: | Line 275: | ||
'''return 0; ''' | '''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 press '''Enter'''. Give a space here | | 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 a space here | ||
− | + | And | |
Type '''“return”''' space '''“0”''' and a semicolon '''“;”.''' | Type '''“return”''' space '''“0”''' and a semicolon '''“;”.''' | ||
Line 310: | Line 310: | ||
| style="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:none;padding:0.097cm;"| Type | ||
− | '''g++ talk.cpp -o output''' | + | '''g++ talk.cpp -o output''' |
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| 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;"| Come back to our terminal | ||
Line 321: | Line 321: | ||
Highlight '''-o output''' | Highlight '''-o output''' | ||
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| '''g++''' is the compiler used to compile '''C++ '''programs | + | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Here '''g++''' is the compiler used to compile '''C++ '''programs |
− | '''talk.cpp''' is | + | '''talk.cpp''' is our filename |
− | '''-o output''' says that the executable should go to the file output. | + | '''-o output''' says that the executable should go to the file output. Now press Enter. |
|- | |- | ||
Line 335: | Line 335: | ||
'''ls -lrt''' | '''ls -lrt''' | ||
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| By typing '''ls -lrt''', we can see that '''output''' is the last file to be created. | + | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| By typing '''ls space -lrt''', we can see that '''output''' is the last file to be created. |
|- | |- | ||
Line 341: | Line 341: | ||
'''./output''' | '''./output''' | ||
− | | style="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 execute the program, |
type dot slash '''“./output” ''' | type dot slash '''“./output” ''' | ||
− | Press '''Enter.''' | + | And Press '''Enter.''' |
|- | |- | ||
Line 358: | Line 358: | ||
| 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 | | 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 | ||
− | + | Switch back to our text editor. | |
|- | |- | ||
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| '''{''' | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;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;"| Suppose we miss the ''' | + | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Suppose here we miss the closing curly bracket'''}''' |
− | |||
|- | |- | ||
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;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;"| save the | + | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Now save the file. |
|- | |- | ||
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;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 execute | + | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Let us execute |
− | + | Come back to our terminal | |
|- | |- | ||
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;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 compile and run the program using the | + | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Now compile and run the program using the commands we used before. |
|- | |- | ||
Line 388: | Line 387: | ||
Highlight '''{''' | Highlight '''{''' | ||
− | | 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 there is an error at line no.7 in our '''talk.cpp''' file | + | | 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. |
− | + | we see that there is an error at line no.7 in our '''talk.cpp''' file | |
+ | That | ||
Expected curly bracket at the end of input. | Expected curly bracket at the end of input. | ||
|- | |- | ||
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;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;"| Come back to our text editor. | + | | 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 text editor. |
|- | |- | ||
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;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 | + | | 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 the closing curly bracket marks the end of the function main |
− | Hence reinsert the bracket . | + | Hence reinsert the bracket here. |
|- | |- | ||
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;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;"| Save | + | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Now Save the file. |
|- | |- | ||
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;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 execute it | + | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Let us execute it again. |
You can recall the previously entered commands by using up arrow key | You can recall the previously entered commands by using up arrow key | ||
Line 420: | Line 420: | ||
| 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="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 | ||
− | Let us switch back to text editor. | + | Let us switch back to our text editor. |
|- | |- | ||
Line 440: | Line 440: | ||
Highlight '''cout''' | Highlight '''cout''' | ||
− | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Come back to terminal.Let us Compile | + | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0.097cm;"| Come back to our terminal.Let us Compile. |
− | We see that there is an error at line no 3 and 6 in our '''talk.cpp''' file that | + | We see that there is an error at line no 3 and line no 6 in our '''talk.cpp''' file that |
expected identifier before '''semicolon''' | expected identifier before '''semicolon''' | ||
Line 458: | Line 458: | ||
|- | |- | ||
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0.097cm;"| | | style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;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 fix the error | + | | 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 |
Come back to our text editor. | Come back to our text editor. | ||
Line 497: | Line 497: | ||
− | | 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 | + | | 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 below |
http://spoken-tutorial.org /What\_is\_a\_Spoken\_Tutorial | http://spoken-tutorial.org /What\_is\_a\_Spoken\_Tutorial | ||
Line 518: | Line 518: | ||
Gives certificates to those who pass an online test | Gives certificates to those who pass an online test | ||
− | For more details, please write to contact @spoken-tutorial.org | + | For more details, please write to contact@spoken-tutorial.org |
|- | |- |
Latest revision as of 14:59, 30 January 2014
Title of script: First C++ program
Author: Ashwini
Keywords: C++ Program, cout<<, cin>>, int main(), Video Tutorial
|
|
Slide 1 | Welcome to the spoken tutorial on First C++ program. |
Slide 2
Learning Objectives |
In this tutorial I am going to explain,
How to write a C++ program. How to compile it. How to execute it. We will also explain some common errors and their solutions. |
Slide 3
System Requirements
|
To record this tutorial, I am using
Ubuntu operating system version 11.10 and G++ Compiler version 4.5.2 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 am using gedit in this tutorial. For relevant tutorial Please visit our website which is as shown: |
Open the Terminal
|
Let me tell you how to write a C++ program through an example
Open terminal Window using Ctrl, Alt and T keys simultaneously on your keyboard. |
gedit talk.cpp & | To open the text editor, type on the terminal
“gedit” space “talk” dot “.cpp” space ampersand “&” sign |
Highlight & | We use the “&” to free up the prompt. |
Highlight .cpp | Please note that all the C++ files will have the extension “.cpp” |
Now Press Enter
The text editor has opened. | |
Let us start to write a program. | |
//My first C++ program | Type double slash “//” space
“My first C++ program”. |
Highlight // | 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. |
Type #include <> | Now press Enter
Type hash “#include” space opening angle bracket “<” closing angle bracket “>”. It is a good practice to complete the brackets first, and then start writing inside it |
Type #include <iostream> | Now, inside the bracket, type
“iostream”. |
Here iostream is a header file
This file includes the declaration of standard input output functions in C++. | |
Type using namespace std; | Now press Enter
Type “using” space “namespace” space “std” and a semicolon “;” |
Highlight using
|
The using statement informs the compiler that you want to use the std namespace
The purpose of namespace is to avoid name collisionsis It is done by localizing the names of identifiers It creates a declarative region and defines a scope Anything defined within a namespace is in the SCOPE of that namespace Here, std is the namespace in which entire standard C++ library is declared. |
Type int main() | Now Press Enter.
Type “int” space “main” opening bracket “(” closing bracket “)” . |
Highlight main() | Main is a special function
It denotes that the execution of the program begins from this line. The opening and the closing bracket is called as parenthesis. |
Highlight () | Parenthesis followed by main tells the user that main is a function. |
Highlight int main() | Here the int main function takes no arguments and 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. | |
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 indicates that main has no arguments The concept of arguments will be discussed in the upcoming tutorials. Now come back to our program. | |
Type { | press Enter.
Type opening curly bracket “{” The opening curly bracket marks the beginning of the function main. |
Type } | Then type closing curly bracket “}”
The closing curly 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 a space here. | |
Type cout << | And type “cout” space two opening angle bracket “<<” |
Highlight cout<< | Here cout is a standard C++ function to print the output on the terminal
|
Type
cout << “Talk to a teacher\n” |
Now after the brackets, type
within the double quotes |
Highlight “” | Anything within the double quotes in the cout << function will be printed.
Now inside the quotes type “Talk to a teacher backslash \n”. |
Highlight \n | Here \n signifies newline
As a result, after execution of the cout function, the cursor moves to the new line. |
Type
“;” |
Every C++ statement must end with a semicolon
Hence type it at the end of this line. |
Highlight ; | Semicolon acts as a statement terminator. |
Type
return 0; |
Now press Enter. Give a space here
And Type “return” space “0” and a semicolon “;”. |
Highlight return 0;
|
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 executable statements. We will learn more about the returned values in another tutorial. |
Save | 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. |
Compile | Let us now compile the program. |
Type
g++ talk.cpp -o output |
Come back to our terminal
Type “g++” space “talk.cpp” space hyphen “-o” space “output”. |
Highlight g++
Highlight talk.cpp Highlight -o output |
Here g++ is the compiler used to compile C++ programs
talk.cpp is our filename -o output says that the executable should go to the file output. Now press Enter. |
We see that the program is compiled. | |
Type
ls -lrt |
By typing ls space -lrt, we can see that output is the last file to be created. |
Type
./output |
Let us execute the program,
type dot slash “./output” And Press Enter. |
Highlight Talk to a teacher | Here the output is displayed as “Talk to a teacher”. |
Errors
|
Now let us see the common errors which we can come across
Switch back to our text editor. |
{ | Suppose here we miss the closing curly bracket}
|
Now save the file. | |
Let us execute
Come back to our terminal | |
Now compile and run the program using the commands we used before. | |
Highlight error
Highlight Line no.7 Highlight talk.cpp Highlight { |
We see an error.
we see that there is an error at line no.7 in our talk.cpp file That Expected curly bracket at the end of input. |
Now Come back to our text editor. | |
As I said before the closing curly bracket marks the end of the function main
Hence reinsert the bracket here. | |
Now Save the file. | |
Let us execute it again.
You can recall the previously entered commands by using up arrow key That is what I did now Yes it is working. | |
Error 2 | I will show you another common error
Let us switch back to our text editor. |
Now, suppose here we missed std. | |
let us Save the file. | |
Highlight error
Highlight Line no.3 and 6 Highlight talk.cpp Highlight ; Highlight cout |
Come back to our terminal.Let us Compile.
We see that there is an error at line no 3 and line no 6 in our talk.cpp file that expected identifier before semicolon and cout was not declared in this scope. |
As cout is the standard C++ library function
and the entire C++ library function is defined under std namespace Hence it is giving an error. | |
Let us now fix the error
Come back to our text editor. type std. here | |
Let us Save it. | |
Let us compile it again
Yes it is working. | |
As an assignment,
Write a program to print your name and city We used single line comment in this tutorial Now just try to give multiline comment Hint: /*.................. .....................*/ | |
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
|
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 |
This is Ashwini Patil from IIT Bombay signing off
Thank you for joining |