SlideShare a Scribd company logo
1 of 2
The first panel (in light blue) shows source code for our first program, The second one (in light gray)
shows result of program once compiled & executed, To left, grey numbers represent line numbers -
these are not part of program, & are shown here merely for informational purposes,
The way to edit & compile program depends on compiler you are using, Depending on whether it has
DevelopmentInterface - not& on its version, Consult compilers section & manual - help included with
your compiler if you have doubts on how to compile C++ console program,
The previousprogramîs typical programthat programmerapprenticeswrite forfirst time, & its result îs
printingonscreenof "HelloWorld!"sentence,itîs one of simplest programs that can be written în C++,
but italreadycontainsfundamentalcomponents that every C++ program has, we are going to look line
by line at code we have just written:
// my first program în C++
This îs comment line, All lines beginning with two slash signs (//) are considered comments & do not
have any effectonbehaviorof program, The programmer can use them to include short explanations -
observations within source code itself, In this case, line îs brief description of what our program is,
#include <iostream>
Linesbeginningwithhash sign (#) are directives for preprocessor, They are not regular code lines with
expressionsbutindicationsforcompiler'spreprocessor, In this case directive #include <iostream> tells
preprocessortoinclude iostreamstandardfile,Thisspecific file(iostream)includesdeclarations of basic
standardinput-outputlibraryînC++, & it îs includedbecause itsfunctionalityîs going to be used later în
program,
Using namespace STD;
All elements of standard C++ library are declared within what îs called namespace, namespace with
name std, So în order to access its functionality we declare with this expression that we will be using
these entities, This line îs very frequent în C++ programs that use standard library, & în fact it will be
included în most of source codes included în these tutorials,
Int main ()
Thisline correspondstobeginningof definitionof mainfunction,The mainfunctionîspointbywhere all
C++ programsstart theirexecution,independentlyof itslocationwithin source code, It does not matter
whether there are other functions with other names defined before - after it - instructions contained
within this function's definition will always be first ones to be executed în any C++ program, For that
same reason, it îs essential that all C++ programs have main function,
The word mainîs followedîncode by pair of parentheses (()), that îs because it îs function declaration:
In C++, what differentiates function declaration from other types of expressions is these parentheses
that follow its name, optionally, these parentheses may enclose list of parameters within them,
Right after these parentheses we can find body of main function enclosed în braces ({}), what îs
contained within these braces îs what function does when it îs executed,
Thisline îs C++ statement,astatementîssimple - compoundexpressionthatcan actually produce some
effect, In fact, this statement performs only action that generates visible effect în our first program,
cout îs name of standard output stream în C++, & meaning of entire statement îs to insert sequence of
characters (in this case Hello World sequence of characters) into standard output stream (cout, which
usually corresponds to screen),
cout îs declared în upstream standard file within std namespace, so that's why we needed to include
that specific file & to declare that we were going to use this specific namespace earlier în our code,
Notice that statement ends with semicolon character (;), This character îs used to mark end of
statement& în fact it must be included at end of all expression statements în all C++ programs (one of
most common syntax errors îs indeed to forget to include some semicolon after statement),
Return 0;
The return statement causes main function to finish, return may be followed by return code (in our
example îsfollowedbyreturncode withvalue of zero),A returncode of 0 for main function îs generally
interpretedasprogramworked as expected without any errors during its execution, This îs most usual
way to end C++ console program,
Relatedlinks:http://www.expertsmind.com/programming-solutions/c-homework-assignment-help.aspx

More Related Content

Viewers also liked

Proyecto de ciencias periodo 4
Proyecto de ciencias periodo 4Proyecto de ciencias periodo 4
Proyecto de ciencias periodo 4Eduardoo Gonzales
 
Evaluationsbericht "Gesundheitsbegleiter"
Evaluationsbericht "Gesundheitsbegleiter"Evaluationsbericht "Gesundheitsbegleiter"
Evaluationsbericht "Gesundheitsbegleiter"TECLA e.V.
 
Presentación personal
Presentación personalPresentación personal
Presentación personalsilviazizur
 
Configuracion de la memoria ran en windows
Configuracion de la memoria ran en windowsConfiguracion de la memoria ran en windows
Configuracion de la memoria ran en windowsmasaquiza-07
 
Inauguran obras en la reforma 30 01 2012
Inauguran obras en la reforma 30 01 2012Inauguran obras en la reforma 30 01 2012
Inauguran obras en la reforma 30 01 2012megaradioexpress
 
Psicologia reporte de los resultados del cuestionario aplicado
Psicologia reporte de los resultados del cuestionario aplicadoPsicologia reporte de los resultados del cuestionario aplicado
Psicologia reporte de los resultados del cuestionario aplicadojesusaronorozcosoto
 
มิ้น ประวัติ
มิ้น ประวัติมิ้น ประวัติ
มิ้น ประวัติKunapon Janpum
 
ข้อสอบ o-net
ข้อสอบ o-netข้อสอบ o-net
ข้อสอบ o-netphasit39910
 

Viewers also liked (16)

รับข้อมูลยอดขาย
รับข้อมูลยอดขายรับข้อมูลยอดขาย
รับข้อมูลยอดขาย
 
Trabajo 2.0
Trabajo 2.0Trabajo 2.0
Trabajo 2.0
 
Ticccc(2)
Ticccc(2)Ticccc(2)
Ticccc(2)
 
la
lala
la
 
Proyecto de ciencias periodo 4
Proyecto de ciencias periodo 4Proyecto de ciencias periodo 4
Proyecto de ciencias periodo 4
 
Evaluationsbericht "Gesundheitsbegleiter"
Evaluationsbericht "Gesundheitsbegleiter"Evaluationsbericht "Gesundheitsbegleiter"
Evaluationsbericht "Gesundheitsbegleiter"
 
Presentación personal
Presentación personalPresentación personal
Presentación personal
 
Configuracion de la memoria ran en windows
Configuracion de la memoria ran en windowsConfiguracion de la memoria ran en windows
Configuracion de la memoria ran en windows
 
Inauguran obras en la reforma 30 01 2012
Inauguran obras en la reforma 30 01 2012Inauguran obras en la reforma 30 01 2012
Inauguran obras en la reforma 30 01 2012
 
Los recursos naturales
Los recursos naturalesLos recursos naturales
Los recursos naturales
 
Laradios
LaradiosLaradios
Laradios
 
Psicologia reporte de los resultados del cuestionario aplicado
Psicologia reporte de los resultados del cuestionario aplicadoPsicologia reporte de los resultados del cuestionario aplicado
Psicologia reporte de los resultados del cuestionario aplicado
 
Autonome voertuigen
Autonome voertuigenAutonome voertuigen
Autonome voertuigen
 
มิ้น ประวัติ
มิ้น ประวัติมิ้น ประวัติ
มิ้น ประวัติ
 
ข้อสอบ o-net
ข้อสอบ o-netข้อสอบ o-net
ข้อสอบ o-net
 
Homofobia
HomofobiaHomofobia
Homofobia
 

Recently uploaded

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 

Recently uploaded (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 

C++ structure of a program

  • 1. The first panel (in light blue) shows source code for our first program, The second one (in light gray) shows result of program once compiled & executed, To left, grey numbers represent line numbers - these are not part of program, & are shown here merely for informational purposes, The way to edit & compile program depends on compiler you are using, Depending on whether it has DevelopmentInterface - not& on its version, Consult compilers section & manual - help included with your compiler if you have doubts on how to compile C++ console program, The previousprogramîs typical programthat programmerapprenticeswrite forfirst time, & its result îs printingonscreenof "HelloWorld!"sentence,itîs one of simplest programs that can be written în C++, but italreadycontainsfundamentalcomponents that every C++ program has, we are going to look line by line at code we have just written: // my first program în C++ This îs comment line, All lines beginning with two slash signs (//) are considered comments & do not have any effectonbehaviorof program, The programmer can use them to include short explanations - observations within source code itself, In this case, line îs brief description of what our program is, #include <iostream> Linesbeginningwithhash sign (#) are directives for preprocessor, They are not regular code lines with expressionsbutindicationsforcompiler'spreprocessor, In this case directive #include <iostream> tells preprocessortoinclude iostreamstandardfile,Thisspecific file(iostream)includesdeclarations of basic standardinput-outputlibraryînC++, & it îs includedbecause itsfunctionalityîs going to be used later în program, Using namespace STD; All elements of standard C++ library are declared within what îs called namespace, namespace with name std, So în order to access its functionality we declare with this expression that we will be using these entities, This line îs very frequent în C++ programs that use standard library, & în fact it will be included în most of source codes included în these tutorials, Int main () Thisline correspondstobeginningof definitionof mainfunction,The mainfunctionîspointbywhere all C++ programsstart theirexecution,independentlyof itslocationwithin source code, It does not matter whether there are other functions with other names defined before - after it - instructions contained
  • 2. within this function's definition will always be first ones to be executed în any C++ program, For that same reason, it îs essential that all C++ programs have main function, The word mainîs followedîncode by pair of parentheses (()), that îs because it îs function declaration: In C++, what differentiates function declaration from other types of expressions is these parentheses that follow its name, optionally, these parentheses may enclose list of parameters within them, Right after these parentheses we can find body of main function enclosed în braces ({}), what îs contained within these braces îs what function does when it îs executed, Thisline îs C++ statement,astatementîssimple - compoundexpressionthatcan actually produce some effect, In fact, this statement performs only action that generates visible effect în our first program, cout îs name of standard output stream în C++, & meaning of entire statement îs to insert sequence of characters (in this case Hello World sequence of characters) into standard output stream (cout, which usually corresponds to screen), cout îs declared în upstream standard file within std namespace, so that's why we needed to include that specific file & to declare that we were going to use this specific namespace earlier în our code, Notice that statement ends with semicolon character (;), This character îs used to mark end of statement& în fact it must be included at end of all expression statements în all C++ programs (one of most common syntax errors îs indeed to forget to include some semicolon after statement), Return 0; The return statement causes main function to finish, return may be followed by return code (in our example îsfollowedbyreturncode withvalue of zero),A returncode of 0 for main function îs generally interpretedasprogramworked as expected without any errors during its execution, This îs most usual way to end C++ console program, Relatedlinks:http://www.expertsmind.com/programming-solutions/c-homework-assignment-help.aspx