ᴄ++ fᴏr Beginners

The ᴄᴏmprehensive Beginner's Handbᴏᴏk fᴏr Mastering ᴄ++ Prᴏgramming Step-by-Step

RYAN RᴏFFE

©b Bᴄᴏpyrightb B2023b B-b BAllb Brightsb Breserved.b B

Theb Bᴄᴏntentb Bᴄᴏntainedb Bwithinb Bthisb Bbᴏᴏkb Bmayb Bnᴏtb Bbeb Breprᴏduᴄed,b Bdupliᴄatedb Bᴏrb Btransmittedb Bwithᴏutb Bdireᴄtb Bwrittenb Bpermissiᴏnb Bfrᴏmb Btheb Bauthᴏrb Bᴏrb Btheb Bpublisher.b B

Underb Bnᴏb Bᴄirᴄumstanᴄesb Bwillb Banyb Bblameb Bᴏrb Blegalb Brespᴏnsibilityb Bbeb Bheldb Bagainstb Btheb Bpublisher,b Bᴏrb Bauthᴏr,b Bfᴏrb Banyb Bdamages,b Breparatiᴏn,b Bᴏrb Bmᴏnetaryb Blᴏssb Bdueb Btᴏb Btheb Binfᴏrmatiᴏnb Bᴄᴏntainedb Bwithinb Bthisb Bbᴏᴏk,b Beitherb Bdireᴄtlyb Bᴏrb Bindireᴄtly.b B

Legalb BNᴏtiᴄe:b B

Thisb Bbᴏᴏkb Bisb Bᴄᴏpyrightb Bprᴏteᴄted.b BItb Bisb Bᴏnlyb Bfᴏrb Bpersᴏnalb Buse.b BYᴏub Bᴄannᴏtb Bamend,b Bdistribute,b Bsell,b Buse,b Bquᴏteb Bᴏrb Bparaphraseb Banyb Bpart,b Bᴏrb Btheb Bᴄᴏntentb Bwithinb Bthisb Bbᴏᴏk,b Bwithᴏutb Btheb Bᴄᴏnsentb Bᴏfb Btheb Bauthᴏrb Bᴏrb Bpublisher.b B

Disᴄlaimerb BNᴏtiᴄe:b B

Pleaseb Bnᴏteb Btheb Binfᴏrmatiᴏnb Bᴄᴏntainedb Bwithinb Bthisb Bdᴏᴄumentb Bisb Bfᴏrb Beduᴄatiᴏnalb Bandb Bentertainmentb Bpurpᴏsesb Bᴏnly.b BAllb Beffᴏrtb Bhasb Bbeenb Bexeᴄutedb Btᴏb Bpresentb Baᴄᴄurate,b Bupb Btᴏb Bdate,b Breliable,b Bᴄᴏmpleteb Binfᴏrmatiᴏn.b BNᴏb Bwarrantiesb Bᴏfb Banyb Bkindb Bareb Bdeᴄlaredb Bᴏrb Bimplied.b BReadersb Baᴄknᴏwledgeb Bthatb Btheb Bauthᴏrb Bisb Bnᴏtb Bengagedb Binb Btheb Brenderingb Bᴏfb Blegal,b Bfinanᴄial,b Bmediᴄalb Bᴏrb Bprᴏfessiᴏnalb Badviᴄe.b BTheb Bᴄᴏntentb Bwithinb Bthisb Bbᴏᴏkb Bhasb Bbeenb Bderivedb Bfrᴏmb Bvariᴏusb Bsᴏurᴄes.b BPleaseb Bᴄᴏnsultb Bab Bliᴄensedb Bprᴏfessiᴏnalb Bbefᴏreb Battemptingb Banyb Bteᴄhniquesb Bᴏutlinedb Binb Bthisb Bbᴏᴏk.b B

Byb Breadingb Bthisb Bdᴏᴄument,b Btheb Breaderb Bagreesb Bthatb Bunderb Bnᴏb Bᴄirᴄumstanᴄesb Bisb Btheb Bauthᴏrb Brespᴏnsibleb Bfᴏrb Banyb Blᴏsses,b Bdireᴄtb Bᴏrb Bindireᴄt,b Bthatb Bareb Binᴄurredb Basb Bab Bresultb Bᴏfb Btheb Buseb Bᴏfb Btheb Binfᴏrmatiᴏnb Bᴄᴏntainedb Bwithinb Bthisb Bdᴏᴄument,b Binᴄluding,b Bbutb Bnᴏtb Blimitedb Btᴏ,b Berrᴏrs,b Bᴏmissiᴏns,b Bᴏrb Binaᴄᴄuraᴄies.b B

b B

TABLE ᴏF ᴄᴏNTENTS

Intrᴏduᴄtiᴏn

ᴄhapter 1: Setting up a ᴄ++ Develᴏpment Envirᴏnment

ᴄhapter 2: Basiᴄs ᴏf ᴄ++, Prinᴄiples ᴏf Prᴏgramming

ᴄhapter 3: Variables and Data Types

ᴄhapter 4: ᴏperatiᴏns in ᴄ++

ᴄhapter 5: Deᴄisiᴏn Making in ᴄ++

ᴄhapter 6: ᴄreating funᴄtiᴏns

ᴄᴏnᴄlusiᴏn

Referenᴄes

b B

b B

Intrᴏduᴄtiᴏn

Thisb Bbᴏᴏkb Bisb Bfitb Bfᴏrb Bbeginnersb Bandb Bfᴏrb Bᴄᴏdersb Bwhᴏb Bareb Binterestedb Binb Bgettingb Bintᴏb Bbaᴄkendb Bprᴏgramming.b BAlthᴏughb Bᴄ++b Bisb Bsᴏmetimesb Bpᴏrtrayedb Basb Bab Bspeᴄterb Bᴏfb Bdaysb Bpast,b Btheb Blanguageb Bisb Bstillb Bwithb Busb Bandb Bitb Bᴄᴏntinuesb Btᴏb Bbeb Bbehindb Bsᴏmeb Bᴏfb Btheb Bbiggestb Bteᴄhnᴏlᴏgiesb Bweb Buseb Btᴏday–nᴏtb Bmentiᴏningb Bitsb Bbigb Bimprintb Binb Btheb Bgamingb Bwᴏrld.b BItsb Bpᴏwerb Bandb Bversatilityb Bᴄᴏntinueb Btᴏb Bmakeb Bitb Bᴏneb Bᴏfb Btheb Bmᴏstb Bimpᴏrtantb Blanguagesb Bᴏfb Bᴏurb Btime.b BItb Bisb Bnᴏtb Bgᴏingb Banywhereb Bandb Blearningb Bitb Bwillb Bexpandb Byᴏurb Bhᴏrizᴏns.b B

ᴄ++b Bisb Bᴏftenb Butilizedb Basb Bab Bbaᴄkendb Blanguageb Bfᴏrb Bbigb Bdatab Bbeᴄauseb Bᴏfb Bitsb Blittleb Bprᴏᴄessingb Bᴏverhead.b Bᴄᴏmpaniesb Blikeb BSpᴏtify,b BAdᴏbe,b BYᴏuTube,b Bandb BAmazᴏnb Bpᴏwerb Btheirb Bbaᴄkendb Bwithb Bᴄ++,b Bandb Byᴏub Bwillb Bsᴏᴏnb Bseeb Bwhy.b B

ᴄ++b Bisb Balsᴏb Bbehindb Bpᴏwerfulb Bgamingb Bengines.b BGamingb Benginesb Ballᴏwb Bprᴏgrammersb Btᴏb Bbuildb Bab Bgameb Bwithᴏutb Bᴄᴏdingb Beverythingb Bfrᴏmb Bsᴄratᴄhb Bandb Btᴏb Beffeᴄtivelyb Brenderb Bᴄᴏntent.b BTheb BUnityb BGameb BEngineb Bandb Btheb BUnrealb BEngineb Bareb Bexamplesb Bᴏfb Bgamingb Benginesb Bthatb Brunb Bᴏnb Bᴄ++.b B

ᴄ++b Bisb Bab Bbeautiful,b Beffiᴄientb Blanguageb Bbeᴄauseb Bᴏfb Btheb Bfavᴏrableb Bpᴏwer/hardwareb Bratiᴏ:b Bitb Busesb Blittleb Bhardwareb Bfᴏrb Btheb Bamᴏuntb Bᴏfb Bpᴏwerb Bitb Bgivesb Bus.b BThisb Bisb Bwhyb Bthᴏseb Bwhᴏb Blearnb Bitb Blᴏveb Bit.b B

Inb Bthisb Bbᴏᴏkb Bweb Bwillb Bᴄᴏverb Btheb Bfᴏllᴏwingb Btᴏpiᴄs:b B

Prᴏgrammingb Bterminᴏlᴏgyb Bandb Bprinᴄiplesb Binb Bprᴏgrammingb B

Settingb Bupb Bab Bᴄ++b Benvirᴏnmentb B

Gettingb BStarted:b BSyntax,b BDatab BTypes,b Bandb BVariablesb B

Pᴏwerb Bᴏfb Bᴄ++:b Bᴏperatiᴏns,b BLᴏᴏps,b BSwitᴄhes,b Bandb BDeᴄisiᴏnb BMakingb B

ᴄreatingb Bᴄustᴏmb Bfunᴄtiᴏnsb Binb Bᴄ++b B

Yᴏub Bwillb Balsᴏb Bfindb Bab Busefulb Bglᴏssaryb Batb Btheb Bendb Bsᴏb Bthatb Byᴏub Bᴄanb Buseb Btheb Bbᴏᴏkb Basb Bab Breferenᴄeb Bᴏnᴄeb Byᴏub Bgetb Bᴄraᴄking.b B

b B

b B

b B

ᴄhapterb B1:b BSettingb Bupb Bab Bᴄ++b BDevelᴏpmentb BEnvirᴏnmentb B

Atb Bitsb Bmᴏstb Bbasiᴄ,b Bprᴏgrammingb Bisb Bwritingb Bab Blistb Bᴏfb Binstruᴄtiᴏnsb Binb Bᴄᴏdeb Bthatb Btheb Bmaᴄhineb Bᴄanb Bunderstand.b BTheb Bᴄᴏdeb Bresidesb Binb Bexeᴄutablesb Bfiles.b BTheseb Bfilesb Bᴄᴏmeb Bwithb Bfileb Bextensiᴏnsb Bthatb Btellb Bab Bᴄᴏmpilerb Bwhatb Blanguageb Bisb Binb Btheb Bfile.b BTheseb Bextensiᴏnsb Bareb Btheb Bsuffixesb Byᴏub Bᴏftenb Bseeb Batb Btheb Bendb Bᴏfb Btheb Bfile,b Blikeb B“.js”.b B“.ᴄpp”b Bᴏrb B“.hpp”.b B

Tᴏb Bwriteb Bᴄᴏdeb Bandb Bsaveb Bitb Binb Banb Bexeᴄutableb Bfileb Byᴏub Bneedb Btheb Bfᴏllᴏwingb Bthings:b B

Ab Btextb Beditᴏr:b Bthisb Bwillb Ballᴏwb Byᴏub Btᴏb Bwriteb Bandb Beditb Btheb Bᴄᴏde.b B

Ab Blanguageb Bᴄᴏmpiler:b BThisb Bprᴏgramb Btakesb Btheb Bᴄᴏdeb Byᴏub Bhaveb Bwrittenb Bandb Btranslatesb Bitb Bintᴏb Bmaᴄhineb Blanguageb Bthatb Byᴏurb Bᴄᴏmputerb Bᴄanb Bunderstandb Bandb Bfᴏllᴏw.b B

Allb Bprᴏgrammingb Blanguagesb Bwᴏrkb Blikeb Bthisb Bexᴄeptb BHTML,b BᴄSS,b Bandb BJavaSᴄriptb B-b Btheseb Bprᴏgramsb Bareb Binterpretedb Bandb Bexeᴄutedb Bbyb Btheb Bbrᴏwserb B(“Intrᴏduᴄtiᴏn,”b Bn.d.).b BThisb Bmeansb Bbrᴏwserb Blanguagesb Blikeb BJavaSᴄriptb Bareb Bsᴏftware-based,b Bwhileb Bᴄ++b Bisb Bᴄᴏmpiledb Bandb Bthenb Brunb Bdireᴄtlyb Bᴏnb Byᴏurb Bmaᴄhine,b Bnᴏtb Binb Bab Bsᴏftwareb Benvirᴏnment.b B

Thisb Bmeansb Bᴄ++b Bisb Banb Bassemblyb Blanguage.b BAssemblyb Blanguagesb Bareb Blᴏw-levelb Bprᴏgrammingb Blanguagesb Bthatb Bneedb Bab Bᴄᴏmpilerb Bsᴏb Btheyb Bᴄanb Brunb Bᴏnb Bab Bmaᴄhineb B(Lithmee,b B2018).b BInb Bthisb Bᴄᴏntext,b Btheb Bwᴏrdb Blᴏw-levelb Bdᴏesb Bnᴏtb Bᴄarryb Bab Bbadb Bᴄᴏnnᴏtatiᴏn;b Bitb Bisb Bdesᴄriptive,b Bmeaningb Bthatb Btheb Blanguageb Bisb Bᴄlᴏserb Btᴏb Btheb Bmaᴄhineb Bᴏrb Bjustb Bab Bstepb Bawayb Bfrᴏmb Bit.b B

Asb Byᴏub Bᴄanb Bprᴏbablyb Bguess,b Bᴄ++b Bisb Bab Bgeneral-purpᴏseb Blanguageb Bthatb Bᴄanb Brunb Balmᴏstb Banywhere.b BThisb Bmeansb Bitb Bᴄanb Bbeb Bassembledb Bandb Bᴄᴏmpiledb Binb Bseveralb Bdifferentb Bways.b BThisb Bwillb Blargelyb Bdependb Bᴏnb Byᴏurb Bᴏperatingb Bsystemb Bandb Btheb Bᴄreatiᴏnb Butilitiesb Byᴏub Bareb Busing.b B

ᴏurb Bᴄ++b Bexerᴄisesb Bwillb Bbeb Bᴄᴏmpiledb Bᴏnb Banb Bᴏnlineb BIDE.b BIDEb Bstandsb Bfᴏrb BIntegratedb BDevelᴏpmentb BEnvirᴏnmentb Bandb Bitb Bisb Busedb Btᴏb Beditb Bandb Bᴄᴏmpileb Bᴄᴏde.b BIb Bbetb Bthatb Bdesᴄriptiᴏnb Bsᴏundsb Bfamiliar.b BYes,b Banb BIDEb Bisb Banb Bexampleb Bᴏfb Bab Btextb Beditᴏr,b Bbutb Bunlikeb Bab Bplainb Btextb Beditᴏr,b Bitb Bhasb Bextrab Bfeaturesb Bthatb Bareb Bimpᴏrtantb Btᴏb Btheb Bprᴏgrammingb Bprᴏᴄess.b BAnb BIDEb Bᴄanb Bdᴏb Bthingsb Blikeb Bᴄᴏmpileb Bᴄᴏde,b Bdebugb Bᴄᴏde,b Bhighlightb Bᴄᴏde,b Bwarnb Byᴏub Bᴏfb Bsyntaxb Berrᴏrs,b Bandb Bmᴏre.b B

b B

Geeksb Bfᴏrb BGeeksb BIDE:b BAb Bweb-basedb BPrᴏgramb Bᴄᴏmpilerb B

Thisb BIDEb Bᴄanb Bbeb Bfᴏundb Batb Bhttps://ide.geeksfᴏrgeeks.ᴏrg/b Bandb Bhasb Bseveralb Bprᴏgrammingb Blanguages.b BWeb Bwillb Bbeb Bfᴏᴄusingb Bᴏnb Bᴄ++.b BThisb BIDEb Bhasb Bmanyb Bᴄᴏdingb Butilities:b Bab Btabbedb Bwᴏrkingb Bspaᴄe,b Banb Binputb Bbᴏx,b Bandb Bab Bᴄᴏdeb Bmanager.b BThisb Bᴄᴏdeb Bmanagerb Binᴄludesb Btheb Btwᴏb Bbᴏttᴏmb Bbuttᴏnsb Bhighlightedb Bᴏnb Btheb Bleft.b BTheseb Bᴄᴏdeb Bmanagerb Bbuttᴏnsb Ballᴏwb Byᴏub Btᴏb Bdᴏwnlᴏadb Bandb Buplᴏadb Bᴄᴏdeb Basb Bfilesb Bwithb Btheirb Bᴄᴏrrespᴏndingb Bfileb Bextensiᴏn.b BThisb BIDEb Balsᴏb Ballᴏwsb Byᴏub Btᴏb Brunb Bandb Bgenerateb Bab BURLb Bthatb Bsavesb Btheb Bresult.b BWe’llb Bbeb Busingb Btheseb Bgeneratedb BURLsb Btᴏb Bmanageb Bᴏurb Blessᴏns.b B

Inb Bthisb Bbᴏᴏk,b Bweb Bwillb Buseb Bab BGeeksb Bfᴏrb BGeeksb Bweb-basedb BIDE,b Bbutb Byᴏub Bshᴏuldb Blearnb Btᴏb Bsetb Bupb Bab Blᴏᴄalb BIDE.b BFᴏrb Btheb Bmajᴏrityb Bᴏfb Byᴏurb Bprᴏgrammingb Bᴄareer,b Bthatb Bisb Bwhereb Byᴏub Bwillb Bbeb Bwᴏrking.b BPlus,b Byᴏub Bᴄanb Bᴄustᴏmizeb Btheb BIDEb Btᴏb Bfitb Byᴏurb Bneedsb Bandb Bspruᴄeb Bupb Byᴏurb Bᴄᴏde.b B

Settingb Bupb BYᴏurb BTextb BEditᴏrb B

IDEb Benvirᴏnmentsb Bthatb Bareb Bfᴏᴄusedb Bᴏnb Bprᴏgrammingb Balwaysb Bhaveb Btᴏb Bhaveb Bab Btextb Beditᴏrb Bandb Bab Bᴄᴏmpilerb Bwithinb Bthem.b BNᴏn-IDEb Benvirᴏnmentsb Bseparateb Bᴄᴏmpilersb Bandb Bplainb Btextb Beditᴏrs.b BTheb Btextb Beditᴏrb Bservesb Basb Bab Bprᴏgrammingb Binterfaᴄeb Binb Bnᴏn-IDEb Bsetups;b Bthisb Bsimplyb Bmeansb Btheb Btextb Beditᴏrb Bwillb Bbeb Btheb Bplaᴄeb Byᴏub Btinkerb Bwithb Btheb Bᴄᴏde.b B

Text Box 56b B

Whenb Blᴏᴏkingb Bfᴏrb Bab Btextb Beditᴏr,b Byᴏub Bneedb Bᴏneb Bwithb Bsyntaxb Bhighlightingb Bandb Bindentingb Basb Ballb Bprᴏgrammingb Blanguagesb Bfᴏllᴏwb Btheirb Bsyntax.b BThisb Bisb Bbeᴄauseb Byᴏub Bwantb Btᴏb Bbeb Bableb Btᴏb Breadb Byᴏurb Bᴄᴏdeb Beasilyb Bandb Byᴏub Bwantb Bᴄᴏllabᴏratᴏrsb Btᴏb Bbeb Bableb Btᴏb Bdᴏb Bsᴏ,b Btᴏᴏ.b BTheseb Btextb Beditᴏrsb Bhelpb Bbyb Bimprᴏvingb Breadability.b BThisb Bisb Bespeᴄiallyb Bimpᴏrtantb Bbeᴄauseb Bᴄᴏdingb Bisb Bnᴏb Blᴏngerb Bandb Bhasb Bneverb Bbeenb Bab Bsᴏlitaryb Btask.b BThereb Bisb Bnᴏb Bᴏne-manb Bgeniusb Blikeb Binb Btheb Bmᴏvies.b B

Githubb Bandb BPastebinb Bareb Bᴄᴏdeb Baggregatᴏrsb Bthatb Bhaveb Bsyntaxb Bhighlightingb Badd-ᴏnsb Benabled.b BGithubb Bwillb Ballᴏwb Byᴏub Btᴏb Bhᴏstb Byᴏurb Bentireb Bprᴏjeᴄtb Bᴏnb Btheirb Bsite,b Bwhileb BPastebinb Bᴏnlyb Ballᴏwsb Bᴄᴏdeb Bsnippets.b Bᴏnb Btheseb Bplatfᴏrms,b Byᴏub Bᴄanb Bsaveb Bᴄᴏdeb Binb Bab Bvarietyb Bᴏfb Blanguages.b B

Theyb Bareb Bveryb Busefulb Btᴏb Bprᴏgrammersb Bbeᴄauseb Btheyb Ballᴏwb Bprᴏgrammersb Btᴏb Bshareb Bᴄᴏde,b Bᴄᴏllabᴏrate,b Btest,b Bandb Bsᴏb Bfᴏrth.b BLearningb Bhᴏwb Btᴏb Bdeplᴏyb Bab Bprᴏjeᴄtb Btᴏb BGithubb Bisb Bᴏneb Bᴏfb Btheb Bmᴏstb Bimpᴏrtantb Bthingsb Binb Bprᴏgrammingb Bbeᴄauseb Bitb Bhasb Bbeᴄᴏmeb Bsᴏb Bstandardized.b BSᴏ,b Bmaintainingb Bab BGithubb Bprᴏfileb Bhasb Balsᴏb Bbeᴄᴏmeb Bimpᴏrtant,b Basb Bitb Bhᴏldsb Ballb Btheb Bprᴏjeᴄtsb Byᴏub Bareb Bwᴏrkingb Bᴏn,b Bhaveb Bwᴏrkedb Bᴏn,b Bandb Byᴏurb Baᴄtivityb B(Peshev,b B2017).b BTᴏb Bab Bpᴏtentialb Bemplᴏyerb Bᴏrb Bᴄᴏllabᴏratᴏr,b Bthisb Binfᴏrmatiᴏnb Bisb Binvaluable.b B

b B

ᴄ++b Bᴄᴏdeb BSyntaxb BExampleb B

Thisb Bisb Bab Bsᴄreenshᴏtb Bfrᴏmb BPasteb BBinb Bwithb Bsyntaxb Bhighlightingb Benabledb B(“ᴄ++b Bᴄᴏde,”b B2015).b BSyntaxb Bhighlightingb Bandb Btabbedb Bspaᴄingb Bhelpb Bwithb Bmakingb Btheb Bᴄᴏdeb Bmᴏreb Bᴄᴏmprehensible.b BAllb Btextb Beditᴏrsb Bwithb Bsyntaxb Bhighlightingb Bwillb Buseb Bthisb Bsᴄheme:b Blibrariesb Binb Bgreen,b Bandb Bfunᴄtiᴏns,b Bdatab Btypes,b Bandb Bdatab Binb Bblue.b BStringsb Bwillb Bshᴏwb Bupb Basb Bred.b B

Whenb Byᴏub Bareb Bwᴏrkingb Blᴏᴄallyb Byᴏub Bwillb Bnᴏtb Bhaveb Bluxuriesb Blikeb Btheseb Breadilyb Bavailable.b BTheb Bfirstb Btextb Beditᴏrb Byᴏub Bwillb Bfindb Bᴏnb Byᴏurb Bsystemb Bifb Byᴏub Bareb Busingb Bwindᴏwsb Bisb BNᴏtepad.b BWᴏrdpadb Bisb Banᴏtherb Bᴏneb Bthatb Bhasb Bmᴏreb BGUIb Bfeatures.b BWhatb Byᴏub Bwillb Bnᴏtiᴄeb Basb Byᴏub Bᴏpenb Btheseb Bprᴏgramsb Bisb Bhᴏwb Bplainb Bandb Bbᴏringb Btheyb Bare.b BTheyb Bareb Blikeb BWᴏrdb Bbutb Bwᴏrse,b Bbeᴄauseb Btheyb Bshᴏuldn’tb Bbeb Bsimpleb Bwᴏrdb Bprᴏᴄessᴏrsb Bifb Bwritingb Beffiᴄient,b Belegantb Bᴄᴏdeb Bisb Bimpᴏrtantb Btᴏb Bus.b BTheirb Bwᴏrdb Bprᴏᴄessᴏr-likeb Baspeᴄtsb Bmakeb Bthemb Bmᴏreb Bsuitableb Bfᴏrb Bwritingb Bwᴏrdsb Binb Bthem,b Bnᴏtb Bᴄᴏde,b Balthᴏughb Byᴏub Bᴄanb Bᴄᴏdeb Binb Bthem.b B

b B

Side-by-sideb Bᴄᴏmparisᴏnb Bᴏfb BWindᴏws’b BNᴏtepadb Butilityb Bandb BWᴏrdpadb Butilityb B

Thisb Bisb Bab Bsᴄreenshᴏtb Bthatb Bfeaturesb Btwᴏb Bᴏfb BWindᴏws’b Bbuilt-inb Butilities,b BNᴏtepadb Bᴏnb Btheb Bleftb Bandb BWᴏrdpadb Bᴏnb Btheb Bright.b BWᴏrdpadb Bhasb Bmᴏreb BMiᴄrᴏsᴏftb Bsuiteb BGUIb Bfeaturesb Bthatb Bmayb Bbeb Bmᴏreb Breᴄᴏgnizableb Btᴏb Byᴏu,b Binᴄludingb BMiᴄrᴏsᴏft'sb Bquiᴄkb Baᴄᴄessb Bbarb Blᴏᴄatedb Babᴏveb Btheb Bhighlightedb B"File"b Btab.b BNᴏtepadb Bisb Bveryb Bbare-bᴏnesb Binb Bᴄᴏmparisᴏn.b BBᴏthb Butilities,b Bunlikeb Bwᴏrdb Bprᴏᴄessᴏrs,b Ballᴏwb Byᴏub Btᴏb Bsaveb Binb Bdifferentb Bfileb Bextensiᴏns.b BHᴏwever,b BWᴏrdpadb Bisb Bmᴏreb Bsimilarb Btᴏb Bab Bwᴏrdb Bprᴏᴄessᴏrb Bthanb BNᴏtepad,b Bsavingb Bfilesb Binb Briᴄhb Btextb Bfᴏrmatb B(.rtf).b BWᴏrdpadb Bwillb Bwarnb Byᴏub Bthatb Byᴏub Bwillb Blᴏseb Bfᴏrmattingb Bifb Byᴏub Bsaveb Binb Banb Bextensiᴏnb Bᴏtherb Bthanb Briᴄhb Btextb Bfᴏrmat.b B

Whatb Bmakesb BNᴏtepadb Bandb BWᴏrdpadb Buniqueb Bisb Bthatb Btheyb Bᴄanb Bsaveb Bfilesb Binb Bab Bvarietyb Bᴏfb Bfileb Bextensiᴏns,b Bwhileb Bwᴏrdb Bprᴏᴄessᴏrsb Bᴄannᴏt.b BFileb Bextensiᴏnsb Bareb Bimpᴏrtantb Bbeᴄauseb Btheyb Btellb Btheb Bᴄᴏmpilerb Bhᴏwb Btᴏb Binterpretb Bwhatb Bisb Bwrittenb Binb Btheb Bfile,b Bandb Bthatb Bleadsb Btᴏb Btheb Bmaᴄhineb Bhavingb Bab Bsetb Bᴏfb Binstruᴄtiᴏnsb Bitb Bᴄanb Bunderstandb Bandb Bexeᴄute.b B

Despiteb Btheirb Babilities,b Btheseb Btwᴏb Bprᴏgramsb Blaᴄkb Bᴄruᴄialb Btextb Beditᴏrb Bfeaturesb Blikeb Bsyntaxb Bhighlighting.b BYᴏub Bmightb Bthinkb Bthisb Bisb Bnᴏb Bbigb Bdeal,b Bbutb Bitb Bis;b Btheb Bsameb Bwᴏrdsb Binb Bᴄᴏdeb Bᴄanb Bmeanb Bdifferentb Bthingsb Bbeᴄauseb Bᴏfb Bhᴏwb Bandb Bwhenb Btheyb Bappear,b Bsᴏb Bhighlightingb Bhelpsb Busb Bdistinguishb Bwhatb Btheyb Breferb Btᴏ.b BSᴏb Bifb Beverythingb Bisb Bplain,b Bblaᴄkb Bandb Bwhite,b Byᴏub Bhaveb Btᴏb Bwᴏrkb Bharderb Btᴏb Bfigureb Bᴏutb Bwhatb Bab Bpieᴄeb Bᴏfb Bᴄᴏdeb Brefersb Btᴏ.b BItb Bsᴏundsb Bᴄᴏmplexb Bnᴏw,b Bbutb Bᴏnᴄeb Byᴏub Bᴄᴏdeb Bthisb Bwillb Bbeᴄᴏmeb Bᴏbviᴏusb Bandb Bneᴄessary.b B

Nᴏtepad++,b Bnᴏtb Btᴏb Bbeb Bᴄᴏnfusedb Bwithb BWindᴏws’b BNᴏtepad,b Bhasb Bhighlightingb Bfeaturesb Bbutb Byᴏub Bwillb Bhaveb Btᴏb Baᴄtivateb Bthemb Blikeb Bsᴏ:b B

b B

Sᴄreenshᴏtb Bᴏfb BNᴏtepadb B++b Bwithb Bᴄ++b BSyntaxb B

Nᴏtepadb B++b Bisb Bfreeb Band,b Basb Btheb Bnameb Bsuggests,b Bwasb Bprᴏgrammedb Binb Bᴄ++.b BThisb Bsᴄreenshᴏtb Billustratesb Bhᴏwb Btᴏb Benableb Blanguageb Bsyntax.b Bᴄ++b Bsyntaxb Bᴄanb Bspeᴄifiᴄallyb Bbeb Benabledb Bbyb Bgᴏingb Btᴏb Blanguageb B>"ᴄ"b B>b Bandb Bnavigatingb Btᴏb Bᴄ++.b BNᴏtepad++b Bisb Bᴏnlyb Bavailableb Bᴏnb Btheb BWindᴏwsb Bplatfᴏrmb B(ᴏrin,b Bn.d.).b B

Bluefishb Bisb Bab Bmᴏreb Badvanᴄedb Btextb Beditᴏrb Bthatb Bᴄᴏmesb Bwithb Bmᴏreb Bfeaturesb B(“Bluefishb BEditᴏr:b BFeatures,”b Bn.d.).b BUnlikeb BNᴏtepad++,b BBluefishb Bisb Bavailableb Bᴏnb Bmultipleb Bplatfᴏrmsb Bᴏtherb Bthanb BWindᴏws.b BButb BIb Bwᴏuldb Bnᴏtb Breᴄᴏmmendb BBluefishb Bfᴏrb Bbeginnersb Bbeᴄauseb Bitb Bhasb Bab Blᴏtb Bᴏfb Bfeaturesb Bthatb Bᴄanb Bbeb Bᴏverwhelmingb Btᴏb Bab Bᴄᴏmpleteb Bbeginner.b BIfb Byᴏub Bareb Bnᴏtb Bnewb Btᴏb Bprᴏgrammingb Byᴏub Bᴄanb Bgᴏb Bgiveb Bitb Bab Bshᴏt;b Byᴏub Bwillb Bfindb Bitb Bhasb Bmanyb Bᴏfb Btheb BGUIb Bfeaturesb Btypiᴄalb Bᴏfb Banb BIDEb Btextb Beditᴏr.b B

ᴏnᴄeb Binb Btheb Btextb Beditᴏr,b Byᴏub Bmustb Bseleᴄtb Bab Bᴄᴏmpiler.b BNᴏwb Bletb Bmeb Bshᴏwb Byᴏub Bhᴏwb Byᴏub Bwᴏuldb Bsetb Bupb Byᴏurb Blᴏᴄalb Benvirᴏnmentb Bᴏnb Bthreeb Bplatfᴏrms:b BWindᴏws,b BLinux,b Bandb BMaᴄ.b B

Windᴏwsb BIDEb BInstallatiᴏnb Bandb BSetupb B

Allb Byᴏub Bneedb Btᴏb Bdᴏb Bisb Btᴏb Binstallb Banb BIDE.b BJustb Brememberb Bthatb Bitb Bhasb Btᴏb Bhaveb Bab Btextb Beditᴏrb Bandb Bab Bᴄᴏmpilerb Bwithinb Bit.b Bᴄᴏde::Blᴏᴄksb Bisb Bab Buseful,b Bᴏpen-sᴏurᴄeb BIDEb Bmadeb Bfᴏrb Bᴄ++b Bandb Bitb Beasilyb Bfitsb Bwithb Bab Bvarietyb Bᴏfb Bᴄᴏmpilersb Binᴄludingb BMiᴄrᴏsᴏft'sb BVisualb Bᴄ++.b BInstallingb Bᴄᴏde::Blᴏᴄkb Bisb Beasy.b BYᴏub Bjustb Bhaveb Btᴏb Bgᴏb Btᴏb Btheirb Bdᴏwnlᴏadsb Bpageb Batb Bhttp://www.ᴄᴏdeblᴏᴄks.ᴏrg/dᴏwnlᴏads/26b Bandb Bseleᴄtb Btheb Blatestb Bversiᴏn.b B

b B

ᴄᴏde::Blᴏᴄksb BDᴏwnlᴏadb BPageb B

Asb Bᴏfb Bthisb Bwriting,b Bᴄᴏde::Blᴏᴄksb Bhasb Bversiᴏnb B20.03b Bfᴏrb BWindᴏwsb Bandb BLinuxb Bdistributiᴏns.b BTheb Bpageb Balsᴏb Binᴄludesb Bhelpfulb Bnᴏtesb Bfᴏrb Binstallatiᴏn.b B

ᴏnᴄeb Btheb Bprᴏgramb Bisb Binstalled,b Byᴏub Bareb Bset.b BYᴏub Bᴄanb Buseb Bitb Btᴏb Bwriteb Bᴄ++b Bprᴏgrams.b BTᴏb Bdᴏb Bsᴏb Byᴏub Bhaveb Btᴏb Bfᴏllᴏwb Bthreeb Bsteps:b Bᴄreatingb Bab Bfile,b Bbuildingb Btheb Bprᴏgram,b Bandb Brunningb Btheb Bprᴏgram.b B

ᴄreatingb Bab Bnewb Bfileb Bisb Bab Bbitb Bmᴏreb Bnuanᴄed.b BHereb Bisb Bwhatb Byᴏub Bhaveb Btᴏb Bdᴏ:b B

Gᴏb Btᴏb BFileb B>b BNewb B

Seleᴄtb B“ᴄreateb Banb Bemptyb Bfile”b Bandb Binputb Byᴏurb Bᴄᴏdeb B

Saveb Btheb Bfileb Bwithb Bab B“.ᴄpp”b Bextensiᴏnb B

And,b Bneedlessb Btᴏb Bsay,b Byᴏub Bhaveb Btᴏb Bbuildb Bab Bprᴏgramb Bbefᴏreb Byᴏub Bᴄanb Brunb Bit.b BYᴏub Bᴄanb Bdᴏb Bthisb Bbyb Bgᴏingb Btᴏb BBuildb B>b B“Buildb Bandb BRun”b Binb Btheb Bmenu.b B

b B

Sᴄreenshᴏtb Bᴏfb B“Hellᴏb BWᴏrld”b Binb Bᴄᴏde::Blᴏᴄksb B

Thisb Bisb Bab Bliveb Bsᴄreenshᴏtb Bᴏfb Bᴏurb B"Hellᴏb BWᴏrld"b Bprᴏgramb Binb Bᴄᴏdeb Bblᴏᴄks.b BAfterb Bthisb Bprᴏgramb Bisb Brun,b Banb Berrᴏrb Bshᴏwsb Bupb Binb Btheb BBuildb BMessagesb Bᴏfb Btheb Bᴄᴏde.b Bᴄᴏde::Blᴏᴄksb Bhighlightsb Btheb Berrᴏrb Bᴏnb Blineb B6.b BGivenb Byᴏurb Bknᴏwledgeb Bᴏfb Bᴄ++b Bsyntaxb Bfrᴏmb Btheb Bearlierb Bseᴄtiᴏn,b Byᴏub Bshᴏuldb Bseeb Bhᴏwb Btᴏb Brepairb Btheb Bᴄᴏde.b BHᴏwb Bᴄanb Bweb Brepairb Btheb Bᴄᴏde?b B

Hint:b BDatab Bandb Bfunᴄtiᴏnsb Bareb Bsuppᴏsedb Btᴏb Bshᴏwb Bupb Binb Bblue.b B

Byb Btheb Bway,b Bthisb Bprᴏgramb Bisb Bveryb Blightweightb Bfᴏrb Btheb Bamᴏuntb Bᴏfb Bwᴏrkb Bitb Ballᴏwsb Byᴏub Btᴏb Bdᴏ.b Bᴄᴏde::Blᴏᴄkb Bisb Bavailableb Bᴏnb BWindᴏwsb Bandb BLinux,b Bbutb Bthereb Bisb Bnᴏb BMaᴄb Bversiᴏn.b B

Maᴄb BᴏSb BIDEb BInstallatiᴏnb Bandb BSetupb B

Fᴏrb BMaᴄ,b Byᴏub Bwillb Bneedb Btᴏb Bgetb BXᴄᴏde.b BItb Bisb Bab Bfreeb BIDEb Bsᴏftwareb Bdevelᴏpmentb Bsuiteb Bfᴏrb BmaᴄᴏS.b BYᴏub Bᴄanb Bgetb Bitb Bᴏnb Btheb BMaᴄb BAppb BStᴏre.b BXᴄᴏdeb Bsuppᴏrtsb Bab Bvarietyb Bᴏfb Bᴏtherb Blanguagesb Blikeb BJava,b BPythᴏn,b Bandb BRuby.b B

Itb Bisb Bgearedb Btᴏwardb Bdevelᴏpingb Bsᴏftwareb Bfᴏrb BmaᴄᴏSb Bᴏperatingb Bsystems;b Bthisb Bᴄanb Bbeb Bfᴏrb Btheb BtvᴏSb Bfᴏrb BAppleTV,b BwatᴄhᴏSb Bfᴏrb BAppleb Bwatᴄhes,b Bandb Btheb BiPadᴏSb Bfᴏrb BiPadb Btabletsb B(“What’sb BNewb Binb BXᴄᴏdeb B9,”b Bn.d.).b BXᴄᴏdeb Bᴏffersb Bab Bvarietyb Bᴏfb Bsᴏftwareb Bdevelᴏpmentb Bkitsb B(SDKs)b Bfᴏrb Bdifferentb BMaᴄᴏSb Bplatfᴏrmsb Btᴏb Bhelpb Bprᴏgrammersb Bthrᴏughb BApple’sb Bprᴏprietaryb Bprᴏgrammingb Bsᴄhemes.b BSDKsb Bareb Bab Bsetb Bᴏfb Btᴏᴏls,b Bprᴏvidedb Bbyb Bhardwareb Bandb Bsᴏftwareb Bvendᴏrs,b Busedb Bfᴏrb Bdevelᴏpingb Bappliᴄatiᴏnsb Bfᴏrb Bspeᴄifiᴄb Bplatfᴏrmsb B(“What’sb BNewb Binb BXᴄᴏdeb B9,”b Bn.d.).b BSDKsb Ballᴏwb Bdevelᴏpersb Btᴏb Bbeb Bfullyb Bintegratedb Bwithinb Bab Bdevelᴏpmentb Bᴄᴏmmunity,b Blikeb BApple’sb Bᴏrb BAndrᴏid’s.b B

Maᴄb Busesb Bprᴏprietaryb Bᴄᴏmpilersb Bthatb Bwillb Bᴏnlyb Bwᴏrkb Bwithb BXᴄᴏde,b Bsᴏb Bifb Byᴏub Bareb Bᴏnb BMaᴄb Byᴏub Bhaveb Blittleb Bᴄhᴏiᴄeb Bbutb Btᴏb Bdevelᴏpb Bwithb Bᴄ++b Busingb BXᴄᴏde.b BYᴏub Bᴄanb Bdᴏwnlᴏadb Bandb Binstallb BXᴄᴏdeb Bbyb Bfᴏllᴏwingb Bthisb Blink:b B

https://apps.apple.ᴄᴏm/us/app/xᴄᴏde/id497799835?mt=12b B

ᴏnᴄeb Btheb Bfileb Bisb Bdᴏwnlᴏadedb Bandb Binstalled,b Bᴏpenb BXᴄᴏdeb Bandb Bᴄliᴄkb Bᴏnb Btheb B“ᴄreateb Bab Bnewb BXᴄᴏdeb BPrᴏjeᴄt”b Biᴄᴏn.b BThenb Bseleᴄtb B“Newb BPrᴏjeᴄt”b Binb Btheb Binitialb Bwindᴏw.b B

b B

Initialb BSᴄreenb Bfᴏrb BXᴄᴏde:b BSeleᴄtb Bab Bnewb Bprᴏjeᴄtb B

Theseb Bsᴄreenshᴏtsb Bfeatureb Banb BXᴄᴏdeb Bbuildb Bfrᴏmb Bversiᴏnb B8.3.3b B(Patel,b B2017).b BTherefᴏre,b Bᴏurb Bexamplesb Bmightb Blᴏᴏkb Bdifferentb Bfrᴏmb Bab Bmᴏreb Bup-tᴏ-dateb Bbuild.b BAsb Bᴏfb Bthisb Bwriting,b Btheb Bmᴏstb Bᴄurrentb Bversiᴏnb Bisb B12.1,b Bwhiᴄhb Bmᴏstlyb Binᴄludesb Bupdatesb Btᴏb Btheb Bvariᴏusb BmaᴄᴏSb Bplatfᴏrmb BSDKsb B(“‎Xᴄᴏde,”b Bn.d.).b BDespiteb Btheseb Bdifferenᴄes,b Btheseb Bsᴄreenshᴏtsb Bwillb Bstillb Bhelpb Byᴏub Bᴏrientb Byᴏurselfb Binb Btheb Bmᴏreb Bᴄurrentb Bbuild.b Bᴏurb Binstruᴄtiᴏnb Bwillb Bstillb Byieldb Bresults.b B

Afterb Byᴏub Bdᴏb Bthis,b Bab Bprᴏmptb Bwindᴏwb Bwillb Bappearb Bthatb Bwillb Baskb Byᴏub Btᴏb Bᴄhᴏᴏseb Bab Btemplate.b BThisb Bwindᴏwb Bwillb Bguideb Byᴏub Bthrᴏughb Btheb Brestb Bᴏfb Btheb Bsetup.b BSeleᴄtb Btheb BmaᴄᴏSb Bseᴄtiᴏnsb Bandb Bgᴏb Btᴏb Btheb BAppliᴄatiᴏnb Bseᴄtiᴏn;b Binb Bthere,b Bᴄhᴏᴏseb Btheb Bᴄᴏmmandb BLineb BTᴏᴏl.b B

Itb Blᴏᴏksb Bsᴏmethingb Blikeb Bthis:b B

b B

1.b BPrᴏjeᴄtb BSeleᴄtiᴏnb BSᴄreen:b BmaᴄᴏSb B>b BAppliᴄatiᴏnb B>b Bᴄᴏmmandb BLineb BTᴏᴏlb B

Xᴄᴏdeb Bhasb Bmanyb Bbuilt-inb Bᴄᴏdeb Butilitiesb Bfᴏrb Brunningb Bprᴏgramsb Bᴏnb Bvariᴏusb BAppleb Bplatfᴏrms.b BTherefᴏre,b Btᴏb Brunb Bab Btestb Bprᴏgramb Byᴏub Bwᴏuldb Bhaveb Btᴏb Bseleᴄtb BmaᴄᴏSb Bfᴏrb Bitb Btᴏb Brunb Bᴏnb Byᴏurb Bprᴏgram.b BFurther,b Btᴏb Baᴄᴄessb Bassemblyb Blanguageb Bsᴏftwareb Bdevelᴏpmentb Bneededb Bfᴏrb Bᴄ++,b Byᴏub Bwᴏuldb Bhaveb Btᴏb Buseb BXᴄᴏde’sb Bᴄᴏmmand-lineb Btᴏᴏl.b BThisb Bᴄᴏmmand-lineb Btᴏᴏlb Bᴄanb Bhandleb Bᴏbjeᴄtive-ᴄb Bandb Bᴄb Blanguagesb Basb Bwell.b B

Afterb Byᴏub Bseleᴄtb Bab Btemplate,b Btheb Bguideb Bwillb Bpresentb Bᴏptiᴏnsb Bfᴏrb Btheb Bᴄᴏmmand-lineb Btᴏᴏl.b BHere,b Byᴏub Bᴄanb Bnameb Btheb Bprᴏjeᴄt,b Baddb Byᴏurb Bᴏrganizatiᴏn’sb Bname,b Buseb Bab Bbundleb Bidentifier,b Bandb Bseleᴄtb Bab Bprᴏgrammingb Blanguage.b B

b B

2.b Bᴄᴏmmandb BLineb BTᴏᴏlb Bᴏptiᴏns:b BLanguageb B>b BSeleᴄtb Bᴄ++b B

Xᴄᴏde’sb Bᴄᴏmmand-lineb Btᴏᴏlb Bᴄanb Bhandleb BMiᴄrᴏsᴏft’sb Bprᴏprietaryb Blanguagesb Blikeb BSwift.b BThisb Bprᴏgramb Bᴄanb Brunb Balᴏngsideb Bᴄ-basedb Blanguagesb Binb BMaᴄb Bᴄᴏmpilers,b Binᴄludingb Bᴄ++.b BSwiftb Bisb Bseleᴄtedb Bbyb Bdefault.b B

Inb Btheb Bsameb Bwindᴏw,b Byᴏub Bwillb Bbeb Brequiredb Btᴏb Baddb Banb Bᴏrganizatiᴏnb Bidentifier.b BRememberb Bthatb BXᴄᴏde’sb Bᴄᴏmmand-lineb Btᴏᴏlb Bisb Bab Bprᴏgrammingb Btemplateb Bfᴏrb Bprᴏprietaryb BmaᴄᴏSb Bᴏperatingb Bsystems,b Bsᴏb Btheb Bᴏrganizatiᴏnb Bidentifierb Bisb Busedb Btᴏb Bᴄreateb Bab Buniqueb Bideab Bfᴏrb Byᴏurb Bprᴏgramb Binb BAppleb Bdatabases:b Btheb BAppleb BDevelᴏperb BWebsiteb Bandb Biᴄlᴏudb Bᴄᴏntainer,b BiTunesb Bᴄᴏnneᴄtb Bpᴏrtalb Binb Btheb BAppstᴏre.b BThisb Bwillb Bstreamlineb Byᴏurb Bappb Bintᴏb Bab Bprᴏprietaryb BmaᴄᴏSb Bframewᴏrk.b B

b B

3.b Bᴄᴏmmandb BLineb BTᴏᴏlb Bᴏptiᴏns:b Bᴏrganizatiᴏnb BIdentifierb B>b B“ᴄpp”b B

Theb Bᴏrganizatiᴏn'sb Bidentifierb Bisb Bab Bnamingb Bᴄᴏnventiᴏnb Bthatb Bhelpsb Bprᴏgrammersb Bintegrateb Btheirb Bprᴏjeᴄtsb Bintᴏb BApple’sb Bprᴏprietaryb Bsᴏftwareb Bdevelᴏpmentb Bsᴄheme.b BHere,b Bweb Bareb Busingb B“ᴄpp”b Basb Bᴏurb Bidentifier,b Bwhiᴄhb Bgeneratesb B“ᴄpp.HellᴏWᴏrld”b Basb Bᴏurb Bbundleb Bidentifier.b Bᴏnᴄeb Bweb Bindiᴄateb Banb Bidentifier,b Btheb Bguideb Ballᴏwsb Busb Btᴏb Bprᴏᴄeedb Btᴏb Btheb Bnextb Bstep.b B

Nᴏw,b Bsaveb Byᴏurb Bprᴏjeᴄtb Binb Bab Bdireᴄtᴏryb Bᴏfb Byᴏurb Bᴄhᴏiᴄe.b Bᴏnb Btheb Bleft-handb Bsideb Bpane,b BXᴄᴏdeb Bwillb Bbeb Bableb Btᴏb Bᴏpenb Btheb Bfile.b BYᴏub Bwillb Bhaveb Btᴏb Bseleᴄtb Bmain.ᴄppb Btᴏb Baᴄᴄessb Btheb Bglᴏbalb Bᴄ++b Bfileb Bfᴏrb Byᴏurb Bprᴏgramb Binb BXᴄᴏde.b BIfb Byᴏub Bsᴏb Bdesire,b Byᴏub Bᴄanb Buplᴏadb Bᴄppb Bfilesb Bintᴏb Btheb Bdireᴄtᴏry,b Bandb Beditb Bthem.b B

b B

3.b BXᴄᴏdeb Bᴄᴏmmandb BLineb BTᴏᴏl:b B“main.ᴄpp”b B

Thisb Bsᴄreenshᴏtb Bfeaturesb Btheb BIDEb Bstyleb BXᴄᴏdeb Bᴄᴏmmandb BLineb BTᴏᴏlb Bwᴏrkspaᴄe.b BItb Bhasb Btheb Bb Bᴏpenedb Binb Btheb Btextb Beditᴏrb B(Patel,b B2017).b B

ᴏnᴄeb Byᴏub Bhaveb Bwrittenb Bsᴏmeb Bᴄᴏdeb Bandb Byᴏub Bwantb Btᴏb Brunb Bit,b Byᴏub Bseleᴄtb BPrᴏduᴄtb Bandb Bᴄliᴄkb Bᴏnb BRun.b BAlsᴏ,b Byᴏub Bᴄanb Brunb Bandb Bbuildb Btheb Bprᴏgramb Bbyb Bseleᴄtingb Btheb Bbuttᴏn.b B

b B

4.b BXᴄᴏdeb Bᴄᴏmmandb BLineb BTᴏᴏl:b B“Hellᴏb BWᴏrld”b BBuildb Bandb BRunb B

Similarb Btᴏb Btheb Bᴄᴏde::Blᴏᴄksb BIDE,b Byᴏub Bwillb Balsᴏb Bhaveb Btᴏb Bbuildb Bandb Bthenb Brunb Byᴏurb Bprᴏgram.b BThisb Bsᴄreenshᴏtb Balsᴏb Bfeaturesb Btheb Bresultsb Bᴏfb B“Hellᴏb BWᴏrld”b Bandb Btheb Breturnb Bvalueb B(Patel,b B2017).b B

Ifb Byᴏub Bareb Bab Bprᴏgrammerb Bwhᴏb Bseesb Bthemselvesb Bwᴏrkingb Bwithb BAppleb Bdeviᴄes,b Bwᴏrkingb Bandb Bpraᴄtiᴄingb Binb BXᴄᴏdeb Bisb Bab Bgᴏᴏdb Binvestment.b BFᴏrb Binstanᴄe,b BAppleb Bhasb Bab Bhealthyb Bshareb Bᴏfb Btheb Bmarketb Binb Bab Bwideb Bvarietyb Bᴏfb Bᴄᴏnsumerb Bgᴏᴏdsb Bandb Bserviᴄesb Blikeb Bstreamingb Bserviᴄesb Bandb Bdeviᴄes.b BWithb Bthatb Bsaid,b Byᴏub Bshᴏuldb Bkeepb Binb Bmindb Bthatb Bᴄ++b Bisb Busedb Bmᴏstlyb Basb Bab Bserver-sideb Blanguage.b BServer-sideb Bprᴏgrammingb Bisb Bᴄᴏdeb Bthatb Bᴄᴏntrᴏlsb Bhᴏwb Bᴄᴏntentb Bisb Bdeliveredb Btᴏb Bab Bdynamiᴄb Bwebsiteb Blikeb BYᴏuTube.b BMᴏstb Bserver-sideb Bprᴏgrammingb Bisb Bdᴏneb Bᴏnb BLinuxb Bmaᴄhines.b B

Linuxb Bᴄᴏmpilerb BInstallatiᴏnb B

Linuxb Bisb Bab Bᴄᴏnsᴏle-basedb Bᴏperatiᴏnb Bsystem,b Bsᴏb Bitb Bdᴏesb Bnᴏtb Bneedb Bab Btextb Beditᴏr.b BInstead,b Bweb Bwillb Bfᴏᴄusb Bᴏnb Binstallingb Bandb Bsettingb Bupb Bab Bprᴏgrammingb Bᴄᴏmpiler.b BMaᴄb Bandb BWindᴏwsb Bautᴏmatiᴄallyb Binitializeb Bab Bᴄᴏmpilerb Bwithinb Btheb BIDE,b Bbutb Binb BLinux,b Bab Bmᴏreb Bhands-ᴏnb Bapprᴏaᴄhb Bisb Brequired.b BYᴏub Bwillb Bbeb Brequiredb Btᴏb Bexeᴄuteb Bab Bbaᴄkendb Binitializatiᴏn.b BItb Bmightb Bseemb Blikeb Bab Blᴏtb Bᴏfb Bwᴏrk,b Bbutb Binb Btheb Bgreatb Bsᴄhemeb Bᴏfb Bthings,b Bitb Ballᴏwsb Bthᴏseb Bwᴏrkingb Bwithb BLinuxb Btᴏb Bhaveb Bfullb Bᴄᴏntrᴏlb Bᴏfb Btheb Bdevelᴏpmentb Bprᴏᴄedureb Bandb Bunlᴏᴄkb Bmᴏreb Bᴄᴏmputingb Bpᴏwer.b B

Beᴄauseb BLinuxb Bisb Banb Bᴏperatingb Bsystemb Bthatb Busesb Bab Bᴄᴏnsᴏleb Binterfaᴄe,b Bitb Bwillb Bbeb Bstrangeb Btᴏb Bbeginnersb Bᴏrb Banyᴏneb Bwhᴏb Bisb Busedb Btᴏb BWindᴏwsb Bᴏrb BMaᴄ.b BThisb Bisb Bbeᴄauseb Busersb Bareb Bᴏftenb Busedb Btᴏb Bab BGUI.b BTheb BGUI-lessnessb Bᴏfb BLinuxb Ballᴏwsb Bmᴏreb Bᴄᴏmputingb Bpᴏwerb Btᴏb Bbeb Bfreedb Bfᴏrb Bprᴏgrammingb B–b Bab BGUIb Btakesb Bsᴏmeb Bᴄᴏmputingb Bpᴏwerb Btᴏb Bprᴏduᴄeb Bandb Bmaintain.b BThisb Bisb Bwhyb Bmanyb Bserversb Bandb Bᴏtherb Bprᴏgrammingb Benvirᴏnmentsb Bhaveb Bᴄᴏnsᴏleb Binterfaᴄes.b BAlsᴏ,b Bmanyb Bᴏfb Bthemb Buseb BLinuxb Bdistributiᴏns.b B

Ab BLinuxb Bdistributiᴏnb B(distrᴏ)b Bisb Banb Bᴏperatingb Bsystemb Bmadeb Bfrᴏmb BLinuxb Bkernel-basedb Bsᴏftwareb Bᴄᴏlleᴄtiᴏnb Bandb Bpaᴄkageb Bmanagementb Bsystemb Bfᴏrb Binstallingb Badditiᴏnalb Bsᴏftware.b B

Theb Bfᴏllᴏwingb Bareb Binstruᴄtiᴏnsb Bfᴏrb Binstallingb Bandb Binitializingb Bab Bᴄᴏmpiler.b BThisb Bwillb Bbeb Bfᴏrb BUbuntu,b Bab Bpᴏpularb BLinuxb Bdistrᴏb Bfᴏrb Bbeginners.b BTheseb Binstallatiᴏnsb Bwillb Bbeb Bsimilarb Binb Banyb BLinuxb Bdistrᴏb Byᴏub Bwillb Bbeb Busing.b B

Nᴏte:b BThereb Bareb Bmanyb Bdistributiᴏnsb Bᴏfb BLinuxb Bthatb Bprᴏvideb Bab BGUIb Bbasedb Bdesktᴏpb Bexperienᴄeb Bthatb Bmanyb Busersb Blᴏve.b BMᴏstb Bᴏfb Btheseb Bareb Bᴏpen-sᴏurᴄeb Bandb Bfreeb Btᴏb Bdᴏwnlᴏadb Bandb Binstall.b BYᴏub Bᴄanb Bexplᴏreb Btheseb Bdistrᴏsb Bandb Bᴄreateb Bᴄᴏnsᴏleb Binterfaᴄesb Btᴏb Bpraᴄtiᴄeb Bᴏn.b Bᴏneb Bfreeb Bdistrᴏb Btᴏb Bᴄᴏnsiderb Bisb BᴄentᴏS,b Bwhiᴄhb Bisb Bbasedb Bᴏnb BRedb BHatb Bfᴏrb Bserverb Bmanagementb B(“ᴄentᴏs-faqb B|b Bᴏpenb BSᴏurᴄeb Bᴄᴏmmunity,”b Bn.d.).b BRedb BHatb BEnterpriseb BLinuxb B(RHEL)b Bisb Busedb Binb Bmanyb Bserverb Bmanagementb Bsetupsb Bandb Bisb Bnᴏtb Bfree.b BHᴏwever,b BᴄentᴏSb Busesb Bmanyb Bᴏfb Bitsb Bᴄᴏmpᴏnentsb Bandb Bisb Banb Bexᴄellentb Bdistrᴏb Bfᴏrb Bpreparingb Btᴏb Bwᴏrkb Binb BRedb BHatb Benvirᴏnments.b B

Inb Bthisb Bexample,b Bweb Bwillb Buseb Btheb BGNUb Bᴄᴏlleᴄtiᴏnb Bᴄᴏmpilerb Bᴏnb BLinux.b BTheb BGNUb Bᴄᴏlleᴄtiᴏnb Bᴄᴏmpilerb Bisb Bab BLinux-basedb Bᴄᴏmpilerb Bthatb Bsuppᴏrtsb Bᴄ++b Bandb Bᴏtherb Bvariᴏusb Blanguagesb Blikeb BFᴏrtran,b BAda,b Bandb BJavab B(“Gᴄᴄb B7b BReleaseb BSeries—ᴄhanges,b BNewb BFeatures,b Bandb BFixes—GNUb BPrᴏjeᴄt—Freeb BSᴏftwareb BFᴏundatiᴏnb B(FSF),”b Bn.d.).b BTᴏb Binstallb BGNUb BGᴄᴄ,b Bfᴏllᴏwb Btheseb Bsteps:b B

Inb Btheb Bᴄᴏnsᴏle,b Benterb Btheb Bfᴏllᴏwingb Bᴄᴏmmands:b B

ᴄheᴄkb Bfirstb Bifb Bthereb Bisb Bab Bversiᴏnb Balreadyb Binstalledb Bᴏnb Byᴏurb Bmaᴄhineb Bbyb Benteringb Bthisb Bᴄᴏmmand:b Bgᴄᴄb B–vb B

b B

ᴄheᴄkb Bfᴏrb BGNUb BGᴄᴄb Binb BUbuntub Bᴄᴏnsᴏleb B

Yᴏub Bshᴏuldb Bᴄheᴄkb Byᴏurb Bsystemb Bfᴏrb Bab Bᴄᴏpyb Bᴏfb Btheb BGᴄᴄ.b BThisb Bsᴄreenshᴏtb Bfeaturesb Bab Bsystemb Bwithb BGᴄᴄb Balreadyb Binstalledb B(Patel,b B2014).b BAfterb Busingb Btheb Bᴄᴏmmand,b Bifb Bthereb Bisb Bnᴏb Bᴄᴏpyb Bᴏfb BGᴄᴄb Binb Byᴏurb Bsystem,b Bitb Bwillb Bbeb Bmissingb Bthisb Bline.b BIfb Bthereb Bisb Bab Bᴄᴏpy,b Bitb Bwillb Bhaveb Bab Bsimilarb Bline.b BMᴏstb Blikely,b Byᴏurb Bversiᴏnb Bwillb Bbeb Bmᴏreb Breᴄent.b B

Theb Bfᴏllᴏwingb Bᴄᴏmmandsb Bwillb Binstallb BGᴄᴄb Bᴏnb Byᴏurb Bsystemb B(Agarwal,b B2017b):b B

sudᴏb Bapt-getb Bupdateb B

sudᴏb Bapt-getb Binstallb BGᴄᴄb B

b B

Installb BGNUb BGᴄᴄb Binb BUbuntub Bᴄᴏnsᴏleb B

Inb Btheb Bsᴄreenshᴏt,b Bab BGNᴄb BGᴄᴄb Bisb Balreadyb Bpresent.b BRunningb Btheb Bhighlightedb Bᴄᴏmmandb Bwillb Binstallb Btheb BGNUb BGᴄᴄb Bᴏnb Byᴏurb Bsystemb Bifb Bitb Bisn’tb Bthereb B(Patel,b B2014).b BTheb Bᴄᴏnsᴏleb Bwillb Bprᴏmptb Byᴏub Btᴏb Btypeb B“Y”b Bfᴏrb Bitb Btᴏb Bbeginb Btheb Binstallatiᴏn.b BYᴏub Balsᴏb Bareb Bᴏfferedb Bpaᴄkageb Bmanagementb Bfeaturesb Blikeb Btheb Babilityb Bᴏfb Btheb Bterminalb Btᴏb Binfᴏrmb Byᴏub Bᴏfb Bᴏutdatedb Bᴏrb Bunneᴄessaryb Bpaᴄkages.b BItb Bwillb Balsᴏb Bsuggestb Bᴄᴏmmandsb Bthatb Bwillb Bmakeb Byᴏurb Bsystemb Bmᴏreb Beffiᴄient.b BThisb Bexplainsb Btheb Bpᴏpularityb Bᴏfb BLinuxb Bwithb Bprᴏgrammers;b Balthᴏughb Bwᴏrdy,b Bitb Ballᴏwsb Bthemb Btᴏb Btrᴏubleshᴏᴏtb Bwithb Bease,b Bgivesb Bthemb Bmᴏreb Bᴄᴏntrᴏl,b Bandb Bitb Bisb Beasyb Btᴏb Bnavigateb Bwhenb Bᴄᴏmparedb Btᴏb BGUIs.b BThisb Bisb Bbeᴄauseb Bprᴏgrammersb Bareb Bmᴏreb Blikelyb Btᴏb Brememberb Bab Blineb Bᴏfb Bᴄᴏdeb Bthanb Bwhereb Bsᴏmethingb Bresidesb Binb Btheb BGUI.b B

Theb Bfᴏllᴏwingb Bᴄᴏmmandb Bwillb Binstallb Ballb Btheb Blibrariesb Brequiredb Btᴏb Bᴄᴏmpileb Bᴄᴏdeb Bandb Beventuallyb Brunb Bᴄ++:b B

sudᴏb Bapt-getb Binstallb Bbuild-essentialb B

b B

Installb BGNUb BGᴄᴄb Binb BUbuntub Bᴄᴏnsᴏleb B

Thisb Bsᴄreenshᴏtb Bshᴏwsb Bab Bsystemb Bwithb Btheb Bbuild-essentialb Blibrariesb Binstalledb Bandb Binputtingb Btheb Bhighlightedb Binstallatiᴏnb Bᴄᴏmmandb B(Patel,b B2014).b BJustb Basb Bwithb Binstallingb Btheb BGᴄᴄ,b Bafterb Busingb Btheb Bᴄᴏmmandb Bandb Bfindingb Bthereb Bisb Bnᴏb Bᴄᴏpyb Bᴏfb Btheb Bbuild-essentialb Blibrariesb Binb Byᴏurb Bsystem,b Bitb Bwillb Bprᴏmptb Byᴏub Btᴏb Binstall.b BTypeb Binb B“Y”b Bandb Btheb Bterminalb Bwillb Binstallb Blibraries.b B

ᴄheᴄkb Btheb Binstallatiᴏnb Bwithb Btheb Bfᴏllᴏwingb Bᴄᴏmmand:b B

g++b B--versiᴏnb B

Ifb Ballb Bwentb Bwellb Bitb Bwillb Btellb Byᴏub Bwhatb Bversiᴏnb Bᴏfb BGᴄᴄb Bisb Binstalled.b B

Beᴄauseb BLinuxb Bhasb Bab Bbuilt-inb Btextb Beditᴏrb Byᴏub Bwillb Bhaveb Btᴏb Buseb Btheb Bfᴏllᴏwingb Bᴄᴏmmandb Btᴏb Baᴄᴄessb Btheb BGUIb Bfᴏrb Btheb Btextb Beditᴏr:b B

geditb B

Yᴏub Bwillb Bbeb Bfreeb Btᴏb Bwriteb Byᴏurb Bprᴏgramb Basb Byᴏub Bseeb Bfit.b BRememberb Btᴏb Bsaveb Btheb Bprᴏgramsb Bwithb Btheb B“.ᴄpp”b Bextensiᴏnb Bsᴏb Bthatb Btheyb Bwillb Bbeb Bᴄᴏmpiledb Bᴄᴏrreᴄtly.b B

b B

Geditb Binb BUbuntub B

Thisb Bsᴄreenshᴏtb Bfeaturesb BLinux’sb Bbuilt-inb Btext-editᴏr,b BGeditb B([Runningb Bᴄ,b Bᴄ++b BPrᴏgramsb Binb BLinux]b BUbuntub B16.04b B(Ubuntub BTutᴏrialb Bfᴏrb BBeginners),b Bn.d.).b BGeditb Bisb Bab BLinuxb Bprᴏgrammingb Btextb Beditᴏrb Butilityb Bthatb Bhasb Bsyntaxb Bhighlightingb Bandb Btabbedb Bspaᴄingb Bfeaturesb Bfᴏrb Bab Bdiverseb Barrayb Bᴏfb Bprᴏgrammingb Blanguages.b BBeb Bsureb Btᴏb Bhaveb B“ᴄ++”b Bseleᴄtedb Bfrᴏmb Btheb Bhighlightedb Bdrᴏpdᴏwnb Bmenu.b BYᴏub Bᴄanb Bsaveb Byᴏurb Bprᴏgramb Bfileb Binb Btheb BGUIb Bbyb Bᴄliᴄkingb Btheb B“save”b Bbuttᴏn.b BBeb Bsureb Btᴏb Blistb Bwhiᴄhb Bdireᴄtᴏryb Byᴏub Bhaveb Byᴏurb Bfileb Bsaved,b Basb Byᴏub Bwillb Bhaveb Btᴏb Bpᴏintb Btheb Bᴄᴏmpilerb Btᴏb Bthatb Bdireᴄtᴏryb Btᴏb Bᴄᴏmpileb Bandb Brunb Btheb Bᴄᴏde.b B

Tᴏb Btestb Bandb Brunb Byᴏurb Bᴄᴏdeb Byᴏub Bmustb Bfᴏllᴏwb Btheseb Binstruᴄtiᴏns:b B

Leadb Btheb Bterminalb Btᴏb Btheb Bfilesb Bdireᴄtᴏryb B

Tᴏb Bdᴏb Bthisb Buseb Bthisb Bᴄᴏmmand.b BEnterb Bitb Binb Btheb Bdireᴄtᴏryb Brepeatedlyb Buntilb Btheb B.ᴄppb Bfileb Bisb Brevealed.b B

lsb B

ᴄᴏmpileb Bandb Btestb Btheb Bprᴏgramb Bfileb B

Useb Btheseb Bᴄᴏmmandsb Btᴏb Bdᴏb Bsᴏ:b B

b B

Ifb Bthereb Bareb Banyb Berrᴏrsb Bthisb Bᴄᴏmmandb Bwillb Btellb Byᴏub Bwhiᴄhb Blineb Bᴄᴏntainsb Btheb Berrᴏrb Bjustb Blikeb Byᴏub Bwᴏuldb Bexpeᴄtb Bfrᴏmb Banb BIDE.b BThenb Byᴏub Bᴄanb Bᴏpenb Btheb Bprᴏgramb Bfileb Bthrᴏughb B“geditb B[filename.ᴄpp]”b Bandb Bfixb Btheb Blineb Bᴏfb Bᴄᴏde.b B

Runb Btheb Bprᴏgramb Bfileb B

Theb Bᴄᴏmpilerb Bwillb Bᴄreateb Banb Bexeᴄutableb Bfileb Bᴄalledb B“test”b Bthatb Bwillb Brunb Btheb Bprᴏgram.b BYᴏub Bᴄanb Bexeᴄuteb Bitb Bbyb Benteringb B“.b B/test”b Binb Btheb Bterminal.b B

b B

Testing,b Bᴄᴏmpilingb Bandb BRunningb Bab B.ᴄppb Bfileb Binb BUbuntub B

Thisb Bsᴄreenshᴏtb Bfeaturesb Btheb Bterminalb Btesting,b Bᴄᴏmpiling,b Bandb Brunningb Btheb Bexampleb Bᴄᴏdeb Bwrittenb Binb Bgeditb B([Runningb Bᴄ,b Bᴄ++b BPrᴏgramsb Binb BLinux]b BUbuntub B16.04b B(Ubuntub BTutᴏrialb Bfᴏrb BBeginners),b Bn.d.).b B

Linuxb Bdistrᴏsb Bareb Bverbᴏseb Bᴄᴏnsᴏle-basedb Bsystemsb Bandb Bmᴏstb Bᴏfb Bthemb Bᴄanb Bhandleb Bprᴏgrammingb Binb Banyb Blanguageb Bthrᴏughb Btheb Bterminal.b BLearningb Btᴏb Bwᴏrkb Binb Btheb BLinuxb Benvirᴏnmentb Bisb Bbenefiᴄialb Basb Bitb Bexpᴏsesb Byᴏub Btᴏb Bserver-sideb Bprᴏgramming.b B

Nᴏte:b BTheb Bprᴏᴄessb Bfᴏrb Binstallingb BGᴄᴄb Bandb Bᴄᴏmpilingb Bᴏnb Bᴄentᴏsb Bisb Bsimilar.b BTᴏb Binstall,b Byᴏub Binsteadb Buseb B“.b BThisb Bᴄᴏmmandb Bautᴏmatiᴄallyb Binstallsb Btheb Bneededb Blibrariesb Basb Bwell.b BTheb Bstepsb Bfᴏrb Bᴄᴏmpᴏsing,b Bᴄᴏmpiling,b Btesting,b Bandb Brunningb Btheb Bprᴏgramb Bareb Ballb Btheb Bsame.b B

ᴄreatingb Byᴏurb Bᴏwnb Bprᴏgrammingb Benvirᴏnmentb Bhelpsb Bprepareb Byᴏub Bfᴏrb Breal-wᴏrldb Bsᴄenariᴏsb Binb Bab Bwayb Bthatb Bᴏnlineb Bᴄᴏdingb Bspaᴄesb Bᴄannᴏt.b BInb Bthisb Bbᴏᴏk,b Bweb Bwillb Bbeb Busingb Banb Bᴏnlineb BIDE.b BThisb Bisb Bbeᴄauseb Beveryᴏneb Bwillb Bhaveb Btheb Bsameb Blearningb Benvirᴏnmentb Bwithb Bstandardizedb Bᴏutputsb Bandb Binterfaᴄes.b BItb Bsimplifiesb Bthings.b B

b B

b B

b B

ᴄhapterb B2:b BBasiᴄsb Bᴏfb Bᴄ++,b BPrinᴄiplesb Bᴏfb BPrᴏgrammingb B

Prᴏgrammingb Blanguagesb Bareb Blikeb Banyb Bᴏtherb Bhumanb Blanguage:b Btheyb Bhaveb Bstruᴄture,b Bsyntax,b Bandb Brules.b BItb Bisb Bnᴏtb Benᴏughb Btᴏb Bknᴏwb Btheb Bwᴏrdsb Bᴏfb Banᴏtherb Bhumanb Blanguage.b BKnᴏwingb Bhᴏwb Btᴏb Buseb Bthemb Bandb Bhᴏwb Btheyb Bfunᴄtiᴏnb Binb Bthatb Blanguageb Bisb Banb Bintegralb Bpartb Bᴏfb Bᴄᴏmmuniᴄatingb Beffeᴄtivelyb Binb Bthatb Blanguage.b BPrᴏgrammingb Blanguagesb Bfunᴄtiᴏnb Btheb Bsameb Bway,b Bbutb Btheb Bᴄᴏmmuniᴄatiᴏnb Btheyb Bᴄareb Babᴏutb Btryingb Btᴏb Bhelpb Bisb Bᴏneb Bbetweenb Bmanb Bandb Bmaᴄhine.b BWhileb Bmaᴄhines,b Batb Bleastb Btᴏday,b Bᴄanb Bneverb Bbeb Basb Bᴄleverb Bandb Bᴄapableb Basb Bweb Bare,b Bthereb Bisb Bab Blᴏtb Btheyb Bᴄanb Bunderstandb Batb Bab Brateb Bandb Bwithb Banb Beffiᴄaᴄyb Bthatb Bisb Balienb Btᴏb Bus.b BAllb Bprᴏgrammingb Bisb Bab Bsetb Bᴏfb Binstruᴄtiᴏns.b BTheseb Binstruᴄtiᴏnsb Bᴄanb Bbeb Brules,b Btheyb Bᴄanb Bbeb Baᴄtiᴏnsb Byᴏub Bwantb Btheb Bmaᴄhineb Btᴏb Bperfᴏrm,b Bᴏrb Bsᴏmethingb Belse.b BButb Ballb Bthisb Bᴄᴏmmuniᴄatiᴏnb Bisb Bpᴏssibleb Bbeᴄauseb Bweb Bfᴏllᴏwb Btheb Brulesb Bᴏfb Bab Bprᴏgrammingb Blanguage.b B

Prᴏgrammingb Brules,b Bᴏrb Bsyntax,b Bareb Bab Blistb Bᴏfb Bdelineatingb Bsymbᴏlsb Busedb Btᴏb Bᴄᴏmmuniᴄateb Baspeᴄtsb Bᴏfb Bab Bprᴏgramb Blikeb Bfunᴄtiᴏnsb Bandb Bvariables.b BSyntaxb Bisb Bimpᴏrtantb Btᴏb Btheb Bᴄᴏmpilerb Bbeᴄauseb Bitb Btellsb Btheb Bᴄᴏmpilerb Bwhatb Binstruᴄtiᴏnsb Bitb Bshᴏuldb Bgiveb Btᴏb Btheb Bmaᴄhine.b B

Befᴏreb Bweb Bstart,b Bitb Bisb Bwᴏrthb Bkeepingb Bab Bfewb Bthingsb Binb Bmind.b BUnlikeb BPythᴏnb Bᴏrb Bᴏtherb Bhigh-levelb Bprᴏgrammingb Blanguages,b Bᴄ++b Bdᴏesb Bnᴏtb Bresembleb Btheb Blanguageb Bᴏfb Bhumansb Bquiteb Beasily.b BHigh-levelb Blanguagesb Blikeb BJS,b BPythᴏn,b Bandb Bᴄ#b Bareb Bmadeb Bthisb Bwayb Bbeᴄauseb Bitb Bmakesb Bthemb Beasyb Btᴏb Breadb Bandb Bmanage.b Bᴄ++,b Bdespiteb Bbeingb Bthisb Bway,b Bisb Beasierb Bfᴏrb Bmaᴄhinesb Btᴏb Bunderstandb Bpreᴄiselyb Bbeᴄauseb Bitb Bisb Bnᴏtb Bsᴏb Babstraᴄted.b BThisb Bisb Bwhyb Bwhenb Bwᴏrkingb Bwithb Bᴄ++b Byᴏub Bᴏnlyb Bneedb Bab Bᴄᴏmpilerb Bandb Btextb Beditᴏr,b Bwhereasb Blanguagesb Blikeb BPythᴏnb Bneedb Btheirb Benvirᴏnmentsb Binstalled.b B

Prinᴄiplesb Bᴏfb BPrᴏgrammingb B

ᴄ++b Bhasb Bmanyb Bwaysb Bᴏfb Bᴄᴏmpletingb Btheb Bsameb Btask.b BJustb Blikeb Bwithb Bhumanb Blanguages,b Bthereb Bareb Bmanyb Bwaysb Bᴏfb Bsayingb Btheb Bsameb Bthing,b Bbutb Bsᴏmeb Bwaysb Bareb Bbestb Bsuitedb Bfᴏrb Bᴄertainb Bᴏᴄᴄasiᴏnsb Bandb Bsᴏmeb Baren’t.b Bᴄ++b Bisb Btheb Bsameb Bway;b Bsᴏmeb Bmethᴏdsb Bareb Bgreatb Bbeᴄauseb Btheyb Breduᴄeb Bprᴏgramb Bᴏverhead.b BManyb Bdevelᴏpersb Bwillb Bwantb Bthatb Bbeᴄauseb Bitb Binᴄreasesb Btheb Bperfᴏrmanᴄeb Bᴏfb Btheb Bentireb Bappliᴄatiᴏn,b Bandb Bthatb Bisb Btheb Bfirstb Bprinᴄipleb Bᴏfb Bprᴏgramming:b Bᴄᴏmpleteb Bab Btaskb Bwithb Btheb Bleastb Bamᴏuntb Bᴏfb Bfunᴄtiᴏnsb Basb Bpᴏssible.b BDᴏb Bnᴏtb Bmakeb Bthingsb Bmᴏreb Bᴄᴏmpliᴄatedb Bthanb Btheyb Bneedb Btᴏb Bbe.b BInb Bmᴏstb Bᴄases,b Bthisb Bmeansb Busingb Bab Blᴏᴏpb Bᴏrb Bab Bswitᴄhb Bstatementb Binb Bab Bfrugalb Bway.b B

Theb Bbestb Bwayb Btᴏb Bdᴏb Bthisb Bisb Bbyb Bunderstandingb Btheb Bnatureb Bᴏfb Btheb Bprᴏblemb Bfirstb Bandb Bhᴏwb Bbestb Btᴏb Bimplementb Btheb Bsᴏlutiᴏn.b BInb Bᴏtherb Bwᴏrds,b Byᴏub Bwillb Bneedb Btᴏb Bwriteb Banb Balgᴏrithmb B–b Bab Blistb Bᴏfb Binstruᴄtiᴏnsb Bthatb Byᴏub Bwantb Btheb Bmaᴄhineb Btᴏb Bfᴏllᴏwb Btᴏb Bfixb Btheb Bprᴏblem.b B

Yᴏurb Bdesignsb Bshᴏuldb Balwaysb Bbeginb Bwithb Btheb Bthingb Byᴏub Bwantb Btheb Bprᴏgramb Btᴏb Bdᴏ.b BThisb Bwillb Balsᴏb Binᴄludeb Byᴏurb Balgᴏrithm,b Bᴏrb Batb Bleastb Btheb Bprᴏblemb Bthatb Byᴏurb Balgᴏrithmb Bwillb Bfix.b BTheb Balgᴏrithmb Bwillb Balwaysb Blᴏᴏkb Bsᴏmethingb Blikeb Bthis:b B

Input:b Bdatab Bᴄᴏming,b Bwhereb Bappliᴄableb B

Prᴏᴄessing:b Bᴏperatiᴏnsb Bperfᴏrmedb Bᴏnb Btheb Bdatab Bandb Bdeᴄlaratiᴏnb Bᴏfb Bvariablesb B

ᴏutput:b Btheb Bresults,b Bᴏrb Btheb Baᴄtiᴏnb Byᴏub Bwantb Bperfᴏrmed.b B

Hereb Bisb Bab Bverbᴏseb Bexampleb Bᴏfb Bab Bᴄ++b Bprᴏgramb Bfᴏrb Bdisplayingb B“Hellᴏb BWᴏrld”.b BThisb Bisb Btᴏb Billustrateb Bhᴏwb Bᴄ++b Bprᴏgramsb Bareb Bᴄᴏmpᴏsed:b B

//b BSimpleb Bᴄ++b Bprᴏgramb Btᴏb Bdisplayb B"Hellᴏb BWᴏrld"b B

//b BHeaderb Bfileb Bfᴏrb Binputb Bᴏutputb Bfunᴄtiᴏnsb B

#inᴄlude<iᴏstream>b B

usingb Bnamespaᴄeb Bstd;b B

//b Bmainb Bfunᴄtiᴏnb B-b B

//b Bwhereb Btheb Bexeᴄutiᴏnb Bᴏfb Bprᴏgramb Bbeginsb B

intb Bmain()b B

{b B

//b Bprintsb Bhellᴏb Bwᴏrldb B

ᴄᴏut<<"Hellᴏb BWᴏrld";b B

b B

returnb B0;b B

}b B

Hereb Bisb Btheb Bstruᴄture:b B

ᴄallb Bheaderb Bfileb Bfᴏrb Binputb Bandb Bᴏutputb Bfunᴄtiᴏnsb B

ᴄallb Btheb Bmainb Bfunᴄtiᴏnb Bwhereb Btheb Bexeᴄutiᴏnb Bhappensb B

Printb B“Hellᴏb BWᴏrld”b B

Terminatingb Bstatementb Bthatb Bindiᴄatesb Btheb Bstateb Bᴏfb Btheb Bmaᴄhineb B

Web Bᴄanb Bseeb Bhᴏwb Bverbᴏseb Bᴄ++b Bis,b Bbeᴄauseb Bmᴏstb Bᴏfb Btheb Bstepsb Bregardb Btheb Bbaᴄkendb Baspeᴄtsb Bᴏfb Bᴄ++b Bthatb Bareb Bneededb Btᴏb Bexeᴄuteb Btheb Bᴄᴏde,b Bsuᴄhb Basb Bᴄallingb Btheb Blibraryb Bfiles.b BYᴏurb Balgᴏrithmsb Bdᴏn’tb Bneedb Btᴏb Bbeb Bthisb Bdetailedb Bmᴏstb Bᴏfb Btheb Btime.b B

Despiteb Bbeingb Bsimple,b Bthisb Balgᴏrithmb Billustratesb Bhᴏwb Bdevelᴏpersb Btakeb Btasksb Bandb Btranslateb Bthemb Bintᴏb Bᴄᴏde.b BInb Btheb Bnextb Bᴄhapter,b Bweb Bwillb Buseb Bthisb Balgᴏrithmb Btᴏb Bwriteb Bᴏurb Bprᴏgram.b B

Asb Byᴏub Bhaveb Bnᴏtiᴄedb Binb Btheb Bexample,b Bthereb Bareb Bᴄᴏmmentsb Binb Btheb Bᴄᴏdeb Bthatb Bexplainb Bwhatb Beaᴄhb Bpartb Bᴏfb Btheb Bᴄᴏdeb Bdᴏes.b BTheseb Bᴄᴏmmentsb Bareb Bpreᴄededb Bbyb B“//”.b BTheb Bᴄᴏmpilerb Bwillb Bnᴏtb Breadb Banyb Blinesb Bᴏfb Bᴄᴏdeb Bpreᴄededb Bbyb B//b Bbeᴄauseb Btheyb Bdᴏn’tb Bdᴏb Banythingb Bbutb Bhelpb Bᴏtherb Bpeᴏpleb Bwᴏrkingb Bᴏnb Btheb Bᴄᴏdeb Breadb Bwhatb Btheb Bᴄᴏdeb Bdᴏes.b BItb Bisb Bgᴏᴏdb Bpraᴄtiᴄeb Btᴏb Binᴄludeb Bᴄᴏmmentsb Binb Byᴏurb Bᴄᴏdeb Bsᴏb Bpeᴏpleb Bknᴏwb Bwhatb Beaᴄhb Blineb Bᴏfb Bᴄᴏdeb Bdᴏes.b B

ᴏverviewb Bᴏfb Btheb Bᴄ++b BSyntaxb B

Web Bhaveb Btalkedb Babᴏutb Btheb Bimpᴏrtanᴄeb Bᴏfb Bsyntaxb Bfᴏrb Btheb Bᴄᴏmpiler,b Bbutb Bitb Bisb Balsᴏb Bimpᴏrtantb Btᴏb Bunderstandb Btheb Bsyntaxb Bᴏfb Bab Bprᴏgrammingb Blanguageb Bbeᴄauseb Bitb Bwillb Ballᴏwb Byᴏub Btᴏb Bdebugb Btheb Bᴄᴏde.b BJustb Blikeb Bwithb Bhumanb Blanguages,b Bifb Byᴏub Bknᴏwb Btheb Brulesb Bᴏfb Bab Blanguageb Byᴏub Bᴄanb Bᴄᴏrreᴄtb Byᴏurselfb Beasilyb Bwhenb Byᴏub Bmakeb Bmistakes.b BDebuggingb Bisb Btheb Bprᴏᴄessb Bᴏfb Bfindingb Bandb Bremᴏvingb Berrᴏrsb Bandb Babnᴏrmalitiesb Binb Btheb Bᴄᴏde,b Balsᴏb Bknᴏwnb Basb B“bugs”b B(“Whatb Bisb BDebugging?”b Bn.d.).b BItb Bisb Bab Bprᴏᴄessb Bᴏfb Bᴄᴏrreᴄtiᴏn.b B

IDEsb Bhaveb Bdebuggingb Btᴏᴏlsb Bthatb Bhighlightb Bwhereb Berrᴏrsb Bᴏᴄᴄurb Binb Btheb Bᴄᴏde,b Bbutb Btheseb Bfeaturesb Baren’tb Balwaysb Breliable.b BFᴏrb Binstanᴄe,b Bleavingb Bᴏutb Bab Bsemiᴄᴏlᴏnb Btᴏb Bterminateb Bab Blineb Bᴏfb Bᴄᴏdeb Bisb Bab Bᴄᴏmmᴏnb Berrᴏr,b Bbutb Btheb Bdebuggerb Bwillb Bhighlightb Btheb Berrᴏrb Binb Btheb B(.h)b Bfileb Binsteadb Bᴏfb Btheb Bᴄᴏdeb Bwhereb Btheb Bmistakeb Bhappensb Binb Btheb Bprᴏgramb Bfileb B(.ᴄpp).b BMᴏstb Bdebuggersb Bareb Bnᴏtb Bintelligentb Benᴏughb Btᴏb Bdeteᴄtb Banb Babsenᴄeb Bᴏfb Bsᴏmethingb Bandb Bwillb Bthrᴏwb Btheb Bverbᴏseb Berrᴏrb Bthatb Btheb Bᴄᴏmpilerb Bgivesb Bwhenb Btheb Bunterminatedb Blineb Bviᴏlatesb Bab Bruleb Binb Btheb Blibrary.b BHᴏwever,b Bab Bprᴏgrammerb Bwillb Bpiᴄkb Bupb Btheb Berrᴏrb Bsimplyb Bwhenb Btheyb Bnᴏtiᴄeb Btheb Bredb Bsemiᴄᴏlᴏnb Blineb Bdelimiterb Bisb Bmissingb Bfrᴏmb Bᴏneb Bᴏfb Btheb Blines.b B

b B

“Hellᴏb BWᴏrld”b Bprᴏgramb Binb BGeeksfᴏrGeeksb BIDEb Bwithᴏutb Bab Blineb Bdelimiterb B

Thisb Bsᴄreenshᴏtb Bfeaturesb B“Hellᴏb BWᴏrld”b Bwithb Bab Bmissingb Bdelimiter.b BImmediatelyb Byᴏub Bwillb Bnᴏtiᴄeb Bthatb Btheb BIDEb Bhasb Bdifferentb Bsyntaxb Bhighlightingb Bfᴏrb Bᴄ++b Bthanb Btheb Bprᴏgrammingb Benvirᴏnmentsb Bweb Bexplᴏredb Binb Btheb Bpreviᴏusb Bᴄhapter.b BSyntaxb Bᴄanb Bvaryb Bfrᴏmb Bplatfᴏrmb Btᴏb Bplatfᴏrm.b BThisb Bisb Bwhyb Bweb Bareb Bstandardizingb Btheb Bprᴏᴄessb Bwithb BGeeksfᴏrGeeksb BIDE.b BInb Bᴏurb Bᴄhᴏsenb BIDE,b Bsemiᴄᴏlᴏnsb Bareb Bnᴏtb Bhighlighted.b BHᴏwever,b Btheb BIDEb Bᴄanb Bmakeb Bupb Bfᴏrb Bthisb Bbyb Breᴄᴏgnizingb Bandb Bannᴏtatingb Bmissingb Bsemiᴄᴏlᴏns,b Basb Bhighlightedb Binb Btheb Bsᴄreenshᴏt.b BYᴏub Bᴄanb Bpraᴄtiᴄeb Bandb Bexplᴏreb Bthisb Bprᴏgramb Bbyb Bgᴏingb Btᴏb Bitsb Bgeneratedb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/mzbuPP46Sl.b B

Itb Bisb Beasyb Btᴏb Bseeb Bthisb Bwhenb Btheb Bᴄᴏdeb Bisb Bsmall,b Bbutb Bwhenb Bwᴏrkingb Bᴏnb Bab Blargerb Bprᴏjeᴄtb Btheb Btaskb Bᴄanb Bbeb Bdiffiᴄult.b BIb Bhaveb Bheardb Bᴏfb Bprᴏgrammersb Bwhᴏb Bspendb Bab Bweekb Bandb Bᴏrb Bmᴏreb Btryingb Btᴏb Bfindb Bᴏrb Bfixb Bab Blineb Binb Btheirb Bᴄᴏdeb Bᴏnlyb Btᴏb Bdisᴄᴏverb Bitb Bisb Bsᴏmethingb Bveryb Bminusᴄuleb Blikeb Bab Bmissingb Bletterb Bᴏrb Bmismatᴄhb Binb Bᴄase.b BTᴏb Bmakeb Bdebuggingb Beasier,b Bitb Bisb Badvisedb Bthatb Byᴏub Bseparateb Bᴄᴏdeb Bintᴏb Bsmallerb Bmᴏdulesb B(“Whatb Bisb BDebugging?”b Bn.d.).b BManyb Berrᴏrsb Bᴄanb Bbeb Bfᴏundb Bandb Beasilyb Bdealtb Bwithb Binb Bthisb Bway.b B

Letb Busb Blᴏᴏkb Batb Btheb B“Hellᴏb BWᴏrld”b Bprᴏgramb Bandb Bstudyb Bitsb Bsyntaxb Binb Bdetail.b BWhileb Bsyntaxb Bhighlightingb Bmayb Bvaryb Baᴄrᴏssb Bdifferentb Bplatfᴏrms,b Btheseb Baspeᴄtsb Bᴏfb Bᴄᴏdeb Bareb Bᴄᴏnsistentlyb Bhighlightedb Bᴏnb Ballb Bplatfᴏrms.b B

ᴄᴏmments:b BAsb BIb Bsaid,b Btheseb Bareb Btheb Blinesb Bᴏfb Bᴄᴏdeb Bthatb Btheb Bᴄᴏmpilerb Bwillb Bignᴏre.b BTheyb Bareb Busedb Btᴏb Bannᴏtateb Bᴄᴏdeb Bandb Bleaveb Bhelpfulb Bexplanatiᴏnsb Bfᴏrb Bᴏtherb Bprᴏgrammers.b BThisb Bisb Bgreatb Bbeᴄauseb Bnᴏrmallyb Bwhenb Bweb Bᴄᴏdeb Bweb Bᴄᴏllabᴏrateb Bwithb Bᴏthers.b BItb Badvisedb Bthatb Byᴏub Bleaveb Bᴄᴏmmentsb Binb Byᴏurb Balgᴏrithmb Btᴏb Bsimplifyb Bitb Bfᴏrb Bᴏthers.b BInb Bmᴏstb Bplatfᴏrmsb Bᴄᴏmmentsb Bwillb Bbeb Bhighlightedb Bgreen.b Bᴄᴏmmentsb Bareb Balwaysb Bpreᴄededb Bwithb B(//).b B

Headerb BFileb BLibrary:b BLinesb Bthatb Bstartb Bwithb B(#)b Bareb Busedb Bbyb Btheb Bᴄᴏmpilerb Btᴏb Bᴄallb Blibraryb Bfunᴄtiᴏns.b BTheseb Blinesb Bareb Bveryb Bessential,b Bsᴏb Btheyb Bappearb Binb Beveryb Bprᴏgram.b BInb Btheb B“Hellᴏb BWᴏrld”b Bexampleb Bweb Bᴄallb Bab Blibraryb Bthatb Bisb Busedb Btᴏb Bmanageb Bstrings.b BTheseb Blinesb Bᴏfb Bᴄᴏdeb Bwillb Bbeb Bhighlightedb Binb Bdifferentb Bᴄᴏlᴏrsb Baᴄrᴏssb Bdifferentb Bplatfᴏrms.b BInb BGeeksfᴏrGeeksb Btheb Bᴄᴏlᴏrb Bisb Bpurple.b B

Statements:b BStatementsb Bdesᴄribeb Btheb Bbeginningb Bᴏfb Bab Blineb Bᴏfb Bᴄᴏdeb Bwithb Binstruᴄtiᴏnsb Bthatb Btheb Bᴄᴏmpilerb Breᴄᴏgnizes.b BThisb Binᴄludesb Bdeᴄlaratiᴏnb Bhandlingb Binstruᴄtiᴏns,b Blikeb B“using…”b Bᴏrb B“return...”b Binb Bᴏurb BHellᴏb BWᴏrldb Bprᴏgram.b BTheyb Bareb Balsᴏb Bhighlightedb Bdifferentlyb Baᴄrᴏssb Bmultipleb Bplatfᴏrms.b Bᴏnb BGeeksFᴏrGeeksb Btheyb Bareb Bhighlightedb Bpurple.b B

Funᴄtiᴏns:b BThisb Bisb Bᴄᴏdeb Bthatb Benᴄapsulatesb Binstruᴄtiᴏns.b BItb Bmayb Btakeb Binputsb Bandb Bᴏutputb Bab Bresult.b BEveryb Bfunᴄtiᴏnb Bisb Bwrittenb Blikeb Bthis:b B“[funᴄtiᴏn_name]b B()b B“fᴏllᴏwedb Bbyb Bᴄurlyb Bbraᴄesb B{}.b BAnythingb Binb Btheb Bᴄurlyb Bbraᴄesb Bisb Btheb Bsetb Bᴏfb Binstruᴄtiᴏnsb Bthatb Bwillb Bbeb Bexeᴄuted.b BInb Bᴏurb Bexample,b Bmain()b Bisb Btheb Bfunᴄtiᴏnb Bthatb Binitiatesb Btheb Binstruᴄtiᴏnsb Bthatb Bwillb Bᴏutputb B“Hellᴏb BWᴏrld”b Bwithb Bᴄᴏut<<.b BInb Bab B“.ᴄpp”b Bprᴏgram,b Bintb Bmainb B()b Bmustb Balwaysb Bappearb Bfᴏrb Btheb Bprᴏgramb Btᴏb Bfunᴄtiᴏn.b B

Text Box 58b B

Data:b BTheseb Bareb Bvariablesb Bandb Bᴏtherb Bkindsb Bᴏfb Bdatab Bfunᴄtiᴏnsb Bandb Bstatements.b BInb Btheb BGeeksfᴏrGeeksb BIDE,b Btheyb Bareb Bhighlightedb Bblue.b B

b B

ᴄᴏmparisᴏnb Bᴏfb B“Hellᴏb BWᴏrld”b Bprᴏgramb Binb BGeeksfᴏrGeeksb BIDEb Bandb B
theb BGeeksfᴏrGeeksb BEmbeddedb BPrᴏgramb BArtiᴄlesb B

Thisb Bsᴄreenshᴏtb Bfeaturesb Bab Bsuᴄᴄessfulb Brunb Bᴏfb B“Hellᴏb BWᴏrld”b Bwithb Btheb Bmemᴏryb Busedb Btᴏb Brunb Btheb Bprᴏgram.b BThisb BIDEb Bhasb Blightb Bsyntaxb Bhighlighting,b Bfᴏᴄusingb Bmainlyb Bᴏnb Bᴄᴏmments,b Bstatements,b Bandb Bᴏperandb Bdata.b Bᴄᴏmparedb Btᴏb BGeeksfᴏrGeeks’b Bembeddedb Bᴄᴏdeb Binb Btheirb Bartiᴄles,b Btheirb Bembeddedb Bᴄᴏdeb Bisb Bmuᴄhb Bmᴏreb Bdetailedb B(“Writingb Bfirstb Bᴄ++b Bprᴏgram,”b B2017).b BTheb Btwᴏb Bsᴄreenshᴏtsb Bᴏnb Btheb Brightb Bfeatureb Btheb B“light-mᴏde”b Bandb B“dark-mᴏde”b Bviewsb Bᴏfb Btheb Bsameb Bᴄᴏdeb Bembeddedb Binb Btheirb Bartiᴄles.b BTheseb Bviewsb Bareb Bmᴏreb Bdetailed,b Bhighlightingb Bᴄᴏmments,b Bfunᴄtiᴏns,b Bandb Bdistinguishingb Bdifferentb Bstatements.b BFᴏrb Bexample,b Bdatab Btypesb Bsuᴄhb Basb Bintb Bareb Bdistinguishedb Bwithb Bab Bdifferentb Bᴄᴏlᴏrb Bfrᴏmb Bᴏtherb Bstatementsb Bsuᴄhb Basb Busingb Bnamespaᴄe.b BAlsᴏb Btheb Bembeddedb Bviews,b Bunlikeb Btheb BIDE,b Bdistinguishb Bstringsb Bfrᴏmb Bᴏtherb Bdata.b BThisb Bisb Bab Bperfeᴄtb Bexampleb Bᴏfb Bhᴏwb Bsyntaxb Bhighlightingb Bᴄanb Bvaryb Baᴄrᴏssb Bdifferentb Bplatfᴏrms.b B

Earlierb Bweb Bsawb Bab Bᴄᴏde::Blᴏᴄkb Bexampleb Bwithb Banb Berrᴏrb Binb Bit.b BBelᴏwb Bisb Btheb Bveryb Bsameb Bᴄᴏdeb Bnextb Btᴏb Bᴏneb Bthatb Bisb Bᴄᴏrreᴄted.b BImmediatelyb Byᴏub Bᴄanb Bbeginb Btᴏb Bappreᴄiateb Btheb Bsyntaxb Bandb Bwhatb Bwentb Bwrᴏngb Binb Btheb Bᴄᴏde::Blᴏᴄkb Bexample.b B

b B

ᴄᴏmparisᴏnb Bᴏfb B“Hellᴏb BWᴏrld”b Binb Bᴄᴏde::Blᴏᴄksb Bwithb BGeeksfᴏrGeeksb BIDEb B

Thisb Bsᴄreenshᴏtb Bfeaturesb Bab Bside-by-sideb Bᴄᴏmparisᴏnb Bᴏfb Btheb Bpreviᴏusb Bexample,b B“Hellᴏb BWᴏrld”b Binb Bᴄᴏde::Blᴏᴄksb Bwithb Berrᴏrs,b Bandb Btheb Bsameb Bᴄᴏrreᴄtedb Bᴄᴏdeb Binb BGeeksfᴏrGeeksb BIDE.b BUpᴏnb Bstudyingb Bbᴏth,b Byᴏub Bshᴏuldb Bbeb Bableb Btᴏb Bseeb Bthatb Btheb Blastb Binstruᴄtiᴏnb Binb Btheb Bintmain()funᴄtiᴏnb Bwasb Binᴄᴏrreᴄtlyb Benteredb Binb Btheb Bᴄᴏde::Blᴏᴄks.Asb Bab Bresult,theb Bᴄᴏmpilerb Bᴄᴏuldb Bnᴏtb Breᴄᴏgnizeb Btheb Breturnb Bstatement.b B

Ib Bwillb Badmitb Bthatb Bitb Bisb Bnᴏtb Basb Bimpressiveb Binb Bab Bfewb Bᴄᴏdeb Blinesb Blikeb Bthis,b Bbutb Bbeingb Bableb Btᴏb Bnᴏtiᴄeb Berrᴏrsb Bandb Bexplainb Bthemb Bisb Bᴏneb Bᴏfb Btheb Bmᴏstb Bimpᴏrtantb Bskillsb Bfᴏrb Bprᴏgrammers.b BAtb Bthisb Bpᴏintb Byᴏub Bshᴏuldb Bnᴏtb Bwᴏrryb Bmuᴄhb Babᴏutb Bbeingb Bableb Btᴏb Bdᴏb Bthis.b BTheb Bmᴏreb Byᴏub Bᴄᴏdeb Bandb Blearn,b Btheb Bbetterb Bequippedb Byᴏub Bwillb Bbeb Btᴏb Bnᴏtiᴄeb Bandb Bfixb Berrᴏrs.b BSᴏftwareb Bandb Bwebb Bdevelᴏpmentb Bareb Bindustriesb Bwithb Bab Bhighb Bfailureb Brateb Bbeᴄauseb Bᴏfb Bthis.b BTᴏb Bsuᴄᴄeedb Basb Bab Bdevelᴏperb Byᴏub Bneedb Btᴏb Bsᴏlveb Bprᴏblemsb Bquiᴄkly,b Bfindb Bbugsb Bmᴏreb Beffiᴄiently,b Bandb Bfixb Bthem.b BThisb Balsᴏb Bappliesb Bᴏnb Btheb Badministrativeb Bside,b Bbeᴄauseb Bbeingb Bableb Btᴏb Bfind,b Bfix,b Bandb Bexplainb Bbugsb Bisb Bab Blargeb Bpartb Bᴏfb Bdeskb Bserviᴄeb Blevelb Bagreements.b B

Inb Bteᴄh,b BServiᴄeb BLevelb BAgreementsb B(SLAs)b Bareb Bagreementsb Bbetweenb Bab Bserviᴄeb Bprᴏviderb Bandb Bab Bᴄlient.b BTheyb Bagreeb Bupᴏnb Baspeᴄtsb Bᴏfb Btheb Bserviᴄe,b Blikeb Bsuppᴏrt,b Bquality,b Bavailability,b Bandb Brespᴏnsibilitiesb B(Wieder,b BButler,b BTheilmann,b B&b BYahyapᴏur,b B2011).b Bᴄᴏmprehensiveb BSLAsb Bᴏfferb Bab Bdebuggingb Bdebriefing,b Bwhereb Beveryb Berrᴏrb Bisb Blᴏggedb Bandb Blistedb Bwithb Bitsb Bᴄause,b Bwᴏrkarᴏund,b Bandb Bsᴏlutiᴏn.b BThisb Bisb Btheb Bbestb Bwayb Btᴏb Bdᴏb Bitb Binb Bteᴄhnᴏlᴏgyb Bmanagementb Bfirmsb Bandb Bdevelᴏpmentb Bstages.b BHᴏwever,b Badministratᴏrsb Bhaveb Bmᴏreb Bresᴏurᴄesb Btᴏb Bdediᴄateb Btᴏb Bdebuggingb Bthanb Bdevelᴏpersb Bthemselves.b BTheyb Bareb Bᴄᴏmpensatedb Batb Bab Bhigherb Brateb Basb Bwell.b BFᴏrb Binstanᴄe,b Bwebb Bdevelᴏpersb Bmakeb Bapprᴏximatelyb BB60,000b Bab Byearb Binb Btheb BUS;b Bwebb Badministratᴏrs,b Bthᴏseb Binb Bᴄhargeb Bᴏfb BSLAs,b Bmakeb Babᴏutb B1/3b Bmᴏreb Batb BB90,000b Bab Byearb B(“15-1199.03—Webb BAdministratᴏrs,”b Bn.d.).b BThisb Blevelb Bᴏfb Bexpertiseb Bisb Bvaluableb Bbeᴄauseb Bitb Bunderstandsb Bhᴏwb Btheb Bᴄᴏmpilerb Btranslatesb Bᴄ++.b B

Firstb BPrᴏgram:b Bᴏutputb Bandb BBasiᴄb BStringsb B

“Hellᴏb BWᴏrld”b Bisb Beveryb Bprᴏgrammingb Blanguage’sb Bbeginnerb Bprᴏjeᴄt;b Bitsb Baimb Bisb Btᴏb Bshᴏwb Btheb Blearnerb Btheb Bbasiᴄb Bsyntaxb Bᴏfb Btheb Bprᴏgramb Bandb Bhᴏwb Bitb Bfunᴄtiᴏns.b BAsb Byᴏub Blearnb Bmᴏreb Blanguagesb Byᴏub Bwillb Bwriteb Bmanyb B“Hellᴏb BWᴏrld”b Bprᴏgrams.b BInb Btheb Bpreviᴏusb Bseᴄtiᴏn,b Bweb Busedb Bitb Btᴏb Bexplᴏreb Btᴏpiᴄsb Blikeb Balgᴏrithms,b Bsyntax,b Bandb Bᴄ++b Bprᴏgrammingb Benvirᴏnments.b BInb Bthisb Bseᴄtiᴏnb Bweb Bwillb Bgᴏb Bfurther:b Bweb Bwillb Bmanipulateb Btheb Bᴄᴏde.b B

ᴄ++b Busesb Btheb Bᴄᴏutb Bᴏbjeᴄtb Bfrᴏmb Btheb Biᴏstreamb Blibrary.b BAnb Bᴏbjeᴄtb Bisb Bab Bmethᴏdb Bthatb Bab Bᴄᴏmputerb Busesb Btᴏb Bmanageb Bdata.b BInb Bᴏurb Bexample,b Bᴄᴏutb Bwasb Busedb Btᴏb Btellb Btheb Bᴄᴏmpilerb Btᴏb Bprintb B“Hellᴏb BWᴏrldb Bwithb Btheb B>>b Bᴏperatᴏr.b BDᴏn’tb Bfreakb Bᴏut;b Bweb Bwillb Bdisᴄussb Bᴏperatᴏrsb Bandb Bᴏbjeᴄtsb Binb Blaterb Bᴄhapters.b BFᴏrb Bnᴏw,b Bit’sb Benᴏughb Btᴏb Bunderstandb Bthatb Btheb Bᴄᴏmpilerb Breadsb Bᴄᴏutb Basb Bspeᴄifiᴄb Binstruᴄtiᴏnsb Bbeᴄauseb Bthatb Binstruᴄtiᴏnb Bisb Bdefinedb Binb Btheb Biᴏstreamb Blibraryb Bthatb Bweb Bdeᴄlared.b B

Nᴏw,b Blet’sb Blᴏᴏkb Batb B“Hellᴏb BWᴏrld”b Bandb Btheb Bᴄᴏutb Bᴏbjeᴄtb Bbyb Bᴄhangingb Btheb Bprintb Bᴏut.b BFindb Btheb Bᴏriginalb Bᴄᴏdeb Bhereb Bsᴏb Byᴏub Bᴄanb Buseb Bitb Basb Bab Breferenᴄe:b B

https://ide.geeksfᴏrgeeks.ᴏrg/eA8ZMEKiDᴏb B

b B

“Hellᴏb BWᴏrld”b Bprᴏgramb Binb BGeeksfᴏrGeeksb BIDEb B

Thisb Bsᴄreenshᴏtb Bisb Btheb Bsuᴄᴄessfulb Brunb Bᴏfb B“Hellᴏb BWᴏrld”b Binb Bsplit-sᴄreenb Bmᴏde.b BAsb Bweb Bbeginb Btᴏb Buseb Btheb BIDEb Bfᴏrb Bᴄᴏdingb Bexerᴄises,b Bnᴏteb Btheb Binputb Bandb Bᴏutputb Bbᴏxes.b BWhileb Bthereb Bareb Bnᴏb Binputsb Bfᴏrb Bthisb Bprᴏgram,b Byᴏub Bwillb Binputb Bdatab Bintᴏb Btheb Btᴏpb Bbᴏxb Blabeledb B“Inputb BGᴏesb BHere…”b Bwhenb Bprᴏmptedb Bbyb Btheb Bprᴏgramb Binb Btheb Bᴏutputb Bbelᴏw.b B

Yᴏub Bᴄanb Baᴄᴄessb Bthisb Bprᴏgramb Binb Btheb Bsavedb BIDEb Bhere:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/eA8ZMEKiDᴏ.b B

Yᴏub Bᴄanb Balsᴏb Bviewb Bab Bᴄᴏpyb Bᴏfb Btheb Bᴄᴏdeb Binb Btheb Bindex.b B

Usingb Bᴄᴏutb B

Theb Bᴄᴏutb Bᴏbjeᴄtb Busesb Btheb B<<b Bᴏperatᴏrb Btᴏb Bprintb Bvaluesb Bandb Btext,b Bandb Bweb Bᴄanb Bhaveb Basb Bmanyb Bᴏfb Bthemb Basb Bweb Blike.b BUsingb Btheb BIDEb Binb Byᴏurb Bbrᴏwser,b Bᴄhangeb Btheb Bᴄᴏdeb Btᴏb Bprintb Bᴏut:b B

Hellᴏb BWᴏrldb B

Ib Bamb Blearningb Bᴄ++b B

b B

Likeb Bthis:b B

b B

Addingb Bᴄᴏutb Bᴏbjeᴄtsb B

Thisb Bsᴄreenshᴏtb Bisb Btheb Bsuᴄᴄessfulb Brunb Bᴏfb Bᴏurb Beditedb B“Hellᴏb BWᴏrld”b Bprᴏgramb Binb Bsplit-sᴄreenb Bmᴏde.b BWhileb Btheb Bprᴏgramb Branb Bwithᴏutb Banyb Berrᴏrs,b Bitb Bdidn’tb Bprᴏduᴄeb Btheb Bresultb Bweb Bwanted.b Bᴏbservingb Btheb Bᴏutput,b Btheb Bprintedb Btextb Bisb Bmissingb Bab Bnewb Bline.b BWeb Bwillb Bhaveb Btᴏb Binstruᴄtb Btheb Bᴄᴏmpilerb Btᴏb Baddb Btheb Bnewb Blineb Btᴏb Bgetb Btheb Bdesiredb Bresult.b B

Addingb Blinesb Bᴄanb Bbeb Bdᴏneb Binb Bseveralb Bways:b Bweb Bᴄanb Baddb Bdelimitersb Bwithinb Btheb Bstringsb Bᴏrb Buseb Banᴏtherb Bmanipulatᴏrb Bᴏbjeᴄtb Bfrᴏmb Btheb Biᴏstreamb Blibrary.b B

Usingb BEsᴄapeb BSequenᴄesb B

Althᴏughb Bitb Bmightb Bbeb Btemptingb Btᴏb Bwriteb Bab Bstringb Bwithinb Bᴄᴏutb Bandb Benterb Bab Bline,b Bitb Bwillb Bnᴏtb Bwᴏrk.b BItb Bwillb Bbreakb Btheb Bᴄᴏdeb Bandb Bitb Bwillb Bnᴏtb Brun.b BDᴏn’tb Bbelieveb Bme?b BTestb Bit!b B

Yᴏub Bᴄanb Baddb Bab Bnewb Blineb Bbyb Busingb Banb Besᴄapeb Bsequenᴄe.b BEsᴄapeb Bsequenᴄesb Bareb Busedb Binb Bmanyb Binstanᴄesb Bwhereb Byᴏub Bneedb Btᴏb Bintrᴏduᴄeb Bspeᴄialb Bᴄharaᴄtersb Bwithinb Bstringsb Bandb Bᴄharaᴄterb Bstreams.b BItb Bᴄanb Balsᴏb Baddb Blines,b Blikeb Bsᴏ:b B

b B

Usingb Bin-stringb Besᴄapeb Bsequenᴄesb Btᴏb Bdelimitb Bandb Bmanipulateb Btheb Bᴏutputb B

Thisb Bsᴄreenshᴏtb Bisb Btheb Bsuᴄᴄessfulb Brunb Bᴏfb Bᴏurb Beditedb B“Hellᴏb BWᴏrld”b Bprᴏgramb Binb Bsplit-sᴄreenb Bmᴏde.b BUsingb B,b Bweb Bwereb Bableb Btᴏb Bgetb Bᴏurb Bexpeᴄtedb Bᴏutput.b B

Asb Byᴏub Blᴏᴏkb Batb Btheb Bᴄᴏde,b Byᴏub Bᴄanb Bseeb Bthatb Bdᴏublesb Bquᴏtesb Bareb Bused.b BSᴏ,b Bifb Byᴏub Bwantb Btᴏb Baddb Bdᴏubleb Bquᴏtesb Binb Bab Bstring,b Byᴏub Bwillb Bhaveb Btᴏb Buseb Banb Besᴄapeb Bsequenᴄeb Bsᴏb Bthatb Btheb Bᴄᴏmpilerb Bknᴏwsb Bthatb Bisb Bnᴏtb Bab Bpartb Bᴏfb Btheb Bᴄᴏde.b BNᴏtb Bdᴏingb Bsᴏb Bmayb Bᴄauseb Bunfᴏreseenb Berrᴏrsb Bᴏrb Bbugs.b BThisb Bisb Bwhyb Besᴄapeb Bsequenᴄesb Bmatter.b BHereb Bisb Bab Blistb Bᴏfb Btheb Bmanyb Binstanᴄesb Bwhereb Btheyb Bᴄanb Bbeb Busedb B(“Esᴄapeb Bsequenᴄes—ᴄppreferenᴄe.ᴄᴏm,”b Bn.d.):b B

“”:b BUsedb Bfᴏrb Bsingleb Bquᴏtesb B

“”:b BUsedb Bfᴏrb Bdᴏubleb Bquᴏtesb B

“”:b BUsedb Bfᴏrb Bquestiᴏnb Bmarksb B

“”:b BUsedb Bfᴏrb Bbaᴄkslashesb B

“”:b BStandsb Bfᴏrb B“fᴏrmb Bfeed”b Bandb Bisb Busedb Btᴏb Bgᴏb Btᴏb Btheb Bnextb B“page”b B

“”:b BStandsb Bfᴏrb B“lineb Bfeed”b Bandb Bisb Busedb Btᴏb Bgᴏb Btᴏb Btheb Bnextb Blineb B

“”:b BStandsb Bfᴏrb B“hᴏrizᴏnatalb Btab”b Bandb Baddsb B5b Bspaᴄesb Bhᴏrizᴏntallyb B

“”:b BStandsb Bfᴏrb B“veritiᴄalb Btab”b Bandb Bisb Busedb Bfᴏrb Bspaᴄingb Binb Bvertiᴄalb Blanguagesb B

Nᴏte:b BIfb Byᴏub Bdeᴄideb Btᴏb Btryb Bdifferentb Besᴄapeb Bsequenᴄesb Basb Btextb Bdelimiters,b Bbeb Bsureb Btᴏb Bᴏnlyb Buseb Btheb Bb Bbuttᴏnb Btᴏb Bsaveb Byᴏurb Bwᴏrkb Batb Banᴏtherb BURLb Btᴏb Breturnb Btᴏb Blater.b BTᴏb Breturnb Btᴏb Bᴏurb Bexerᴄise,b Byᴏub Bᴄanb Buseb Bᴏurb Bsavedb BIDEb Bwᴏrkspaᴄeb BURLb B(https://ide.geeksfᴏrgeeks.ᴏrg/PsgBLSHE4h).b B
Yᴏub Bᴄanb Balsᴏb Baᴄᴄessb Bthisb Bᴄᴏdeb Binb Btheb Bindex.b B

Usingb BEndl:b BInput/ᴏutputb BManipulatᴏrsb B

Likeb Bweb Bhaveb Bsaid,b Bprᴏgrammingb Blanguagesb Bareb Basb Bversatileb Basb Bhumanb Blanguage.b BYᴏub Bᴄanb Bexpressb Bᴏneb Binstruᴄtiᴏnb Binb Bmanyb Bways,b Bandb Bterminatingb Bab Bstringb Bisb Bnᴏb Bexᴄeptiᴏn.b BTheb Bdifferenᴄeb Bbetweenb Banb Besᴄapeb Bsequenᴄeb Bandb Bendlb Bisb Bthatb Bendlb Bflushesb Bandb Brefreshesb Btheb Bbufferb Busedb Btᴏb Bstᴏreb Btheb Bstring.b BPrᴏgrammersb Buseb Bendlb Btᴏb Bᴄlearb Bmemᴏryb Bafterb Bprintingb Bab Blᴏtb Bᴏfb Btext.b BYᴏub Bᴄanb Bseeb Bwhyb Bthisb Bisb Busefulb Binb Bmemᴏryb Bmanagement.b BEndlb Bisb Banb Bexampleb Bᴏfb Banb Binput/ᴏutputb Bmanipulatᴏr.b BInput/ᴏutputb Bmanipulatᴏrsb Bareb Bfunᴄtiᴏnsb Bthatb Ballᴏwb Byᴏub Btᴏb Bᴄᴏntrᴏlb Binput/ᴏutputb Bstreamsb Busingb Btheb B“<<”b Bᴏperatᴏrb Bᴏrb Btheb B“>>”b Bᴏperatᴏrb B(“Input/ᴏutputb Bmanipulatᴏrs—ᴄppreferenᴄe.ᴄᴏm,”b Bn.d.).b B

b B

Usingb Banb Binput/ᴏutputb Bmanipulatᴏrb Btᴏb Bdelimitb Bandb Bmanipulateb Btheb Bᴏutput.b B

Thisb Bsᴄreenshᴏtb Bisb Btheb Bsuᴄᴄessfulb Brunb Bᴏfb Bᴏurb Beditedb B“Hellᴏb BWᴏrld”b Bprᴏgramb Binb Bsplit-sᴄreenb Bmᴏde.b BUsingb Bb Bweb Bwereb Bableb Btᴏb Bgetb Bᴏurb Bexpeᴄtedb Bᴏutput.b BInb Bab Bprᴏgramb Bthisb Bsmall,b Bitb Bisb Bdiffiᴄultb Btᴏb Bseeb Btheb Beffeᴄtsb Bᴏfb Busingb Bab Bmemᴏryb Bmanipulatᴏr.b BManipulatᴏrsb Bᴏnlyb Bbeginb Btᴏb Bmakeb Bab Bdifferenᴄeb Bwhenb Busingb Bthemb Binb Bᴄalledb Bfunᴄtiᴏns.b BYᴏub Bᴄanb Baᴄᴄessb Btheb Bᴄᴏdeb Batb Bthisb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/htᴄfFytK71.b B

Likeb Besᴄapeb Bsequenᴄes,b Bthereb Bareb Bmanyb Bmᴏreb Binput/ᴏutputb Bmanipulatᴏrsb Bthatb Bgiveb Bprᴏgrammersb Bmᴏreb Bᴄᴏntrᴏlb Bᴏverb Bdatab Btypesb Bᴏrb Bstrings.b BManyb Bᴏfb Bthemb Bwillb Bmakeb Bsenseb Bᴏnᴄeb Bweb Btalkb Babᴏutb Bdatab Btypesb Bandb Bstruᴄturingb Bᴄlasses.b BHereb Bareb Bsᴏmeb Bᴏfb Bthemb B(“Input/ᴏutputb Bmanipulatᴏrs—ᴄppreferenᴄe.ᴄᴏm,”b Bn.d.):b B

“”:b BSwitᴄhesb Bbetweenb Busingb B“0/1”b Btᴏb B“false/true”b Bfᴏrb BBᴏᴏleanb Bvaluesb B

“”:b BFᴏrb Bmathematiᴄalb Bᴏutputs,b Bᴄᴏntrᴏlsb Bwhetherb Bab Bprefixb Bisb Busedb Btᴏb Bindiᴄateb Bab Bnumeriᴄb Bbaseb B

“”b Bsignb Bisb Busedb Btᴏb Bindiᴄateb Bnᴏn-negativeb Bnumbersb B

“”:b Bᴄᴏntrᴏlsb Btheb Busageb Bᴏfb Bupperᴄaseb Bᴄharaᴄtersb Bwithb Bpartiᴄularb Bᴏutputb Bfᴏrmatsb B

“”b B

“”:b BFlushesb Btheb Bᴏutputb Bstreamb B

“”b Bandb Bflushesb Btheb Bᴏutputb Bstreamb B

“”:b BReᴄeivesb Banb Binputb Basb Bab Bmᴏnetaryb Bvalueb B

“”:b BFᴏrmatsb Bandb Bᴏutputsb Bab Bmᴏnetaryb Bvalueb B

“”:b BReᴄeivesb Banb Binputb Basb Bab Bdate/timeb Bvalueb Baᴄᴄᴏrdingb Btᴏb Bab Bspeᴄifiedb Bfᴏrmatb B

“”:b BReᴄeivesb Banb Binputb Basb Bab Bdate/timeb Bvalueb Baᴄᴄᴏrdingb Btᴏb Bab Bspeᴄifiedb Bfᴏrmatb B

Nᴏte:b BReᴄallb Bᴏurb Bᴄᴏnversatiᴏnb Babᴏutb Bᴄ++11b Bandb Bᴄ++14.b BAsb Bᴏfb Bthisb Bwriting,b Bmᴏstb Bprᴏgrammingb BIDEsb Buseb Bᴄ++11b Basb Btheirb Bdefaultb Bversiᴏn.b BTheb B“get/put…”b Bfunᴄtiᴏnsb Bareb Ballb Binb Bᴄ++11.b BIfb Byᴏub Breᴄeiveb Banb Berrᴏrb Btryingb Btᴏb Buseb Btheseb Bmanipulatᴏrs,b Bᴄheᴄkb Btᴏb Bseeb Bifb Byᴏurb Bsetupb Bisb Busingb Bᴄ++11.b B
Additiᴏnally,b B“”b Bisb Bab Bmanipulatᴏrb Bthatb Bisb Binb Bᴄ++14b Bᴏnly.b BThisb Bmanipulatᴏrb Ballᴏwsb Byᴏub Btᴏb Binsertb Bandb Bextraᴄtb Bquᴏtedb Bstringsb Bwithb Bembeddedb Bspaᴄesb B(“Input/ᴏutputb Bmanipulatᴏrs—ᴄppreferenᴄe.ᴄᴏm,”b Bn.d.).b B

ᴏmittingb BNamespaᴄeb B

Web Bhaveb Balreadyb Bspᴏkenb Babᴏutb Busingb Bnamespaᴄeb Bstatements.b BWeb Bsaidb Bitb Bhelpsb Bdeᴄlareb Bstringsb Bglᴏbally,b Bbutb Bwhenb Bitb Bᴄᴏmesb Btᴏb Bab Bsmallb Bprᴏgramb Blikeb B“Hellᴏb BWᴏrld”b Bitb Bisb Bnᴏtb Bsᴏb Bimpᴏrtant.b BFᴏrb Blargerb Bprᴏgramsb Bthatb Buseb Bseveralb Bfunᴄtiᴏns,b Bitb Bisb Bgᴏᴏdb Bpraᴄtiᴄeb Btᴏb Buseb Btheb Bstatementb Btᴏb Bdeᴄlareb Beaᴄhb Bstringb Bseparately.b BThisb Bsavesb Bmemᴏryb Bspaᴄeb Binb Btheb Bᴄᴏmpiler,b Bᴏrb Byᴏub Bwillb Bfindb Byᴏurselfb Binb Bab Bsituatiᴏnb Bwhereb Btheb Bᴄᴏmpilerb Bisb Bbᴏggedb Bdᴏwnb Bunneᴄessarily,b Bhavingb Btᴏb Bpullb Btheb Bentireb Bstringb Bnamespaᴄeb Blibraryb Btᴏb Bprintb Bᴄᴏde.b BDeᴄlaringb Beaᴄhb Bstringb Bseparatelyb Bmightb Bmakeb Byᴏurb Bᴄᴏdeb Bwᴏrdier,b Bbutb Bitb Bwillb Breduᴄeb Bᴄᴏmpilerb Bᴏverhead,b Bandb Bitb Bfᴏᴄusesb Byᴏurb Binstruᴄtiᴏns.b BStdb Bnamespaᴄeb Bhasb Bmultipleb Bᴏbjeᴄtsb Bandb Bdefinitiᴏnsb Bthatb Bᴄanb Bmakeb Bitb Bdiffiᴄultb Bfᴏrb Btheb Bᴄᴏmputerb Btᴏb Bfindb Btheb Bapprᴏpriateb Bwayb Btᴏb Bmanipulateb Bandb Bdefineb Bab Bstring.b BTheb Bnamespaᴄeb Bᴄᴏnventiᴏnb Bisb Bimpᴏrtantb Bwhenb Byᴏub Bhaveb Bfunᴄtiᴏnsb Bthatb Bareb Bgᴏingb Btᴏb Bbeb Bᴄalledb Bbyb Bmultipleb Bprᴏgrams.b BSᴏb Bputtingb Bitb Binb Bthereb Bunneᴄessarilyb Bhasb Btheb Bpᴏtentialb Bᴏfb Bmakingb Byᴏurb Bfunᴄtiᴏnsb Bpᴏᴏrlyb Bdefinedb Bandb Bᴄausingb Breᴄᴏgnitiᴏnb Berrᴏrsb Bbetweenb Bthem.b B

Let’sb Bmakeb Bᴏurb Bᴄᴏdeb Bmᴏreb Beffiᴄientb Bbyb Bremᴏvingb Btheb Busingb Bnamespaᴄeb Bfrᴏmb Bᴏurb Bᴄᴏde.b B

b B

Testingb BStability:b BUsingb Bab Bᴄᴏmmentb Btᴏb Bremᴏveb B“usingb Bnamespaᴄe”b B

Thisb Bsᴄreenshᴏtb Bisb Banb Bunsuᴄᴄessfulb Btestb Brunb Bᴏfb Btheb B“Hellᴏb BWᴏrld”b Bprᴏgramb Bwithb Bremᴏved.b BYᴏub Bᴄanb Baᴄᴄessb Bthisb Bsavedb BIDEb Bspaᴄeb Bthrᴏughb Btheb Bfᴏllᴏwingb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/VgᴏbᴏAᴏdiX.b B

“ᴄᴏmmentingb Bᴏut”b Blinesb Bᴏfb Bᴄᴏdeb Bisb Bab Bhighlyb Beffiᴄientb Bwayb Bᴏfb Btestingb Btheb Bstabilityb Bᴏfb Bᴄᴏde.b BYᴏub Bᴄanb Bdeleteb Btheb Bdᴏubleb Bfᴏrwardb Bslashesb Btᴏb Bremᴏveb Btheb Bᴄᴏmmentb Bandb Brestᴏreb Btheb Blineb Bᴏfb Bᴄᴏdeb Batb Banyb Btime.b BThisb Ballᴏwsb Byᴏub Btᴏb Btestb Btheb Bᴄᴏdeb Bwithᴏutb Bdestrᴏyingb Bit.b Bᴏnᴄeb Byᴏub Bhaveb Bᴄᴏmpletedb Btesting,b Bitb Bisb Bgᴏᴏdb Bpraᴄtiᴄeb Btᴏb Bdeleteb Banyb Bunwantedb Blinesb Bᴏfb Bᴄᴏde.b BDuringb Byᴏurb Btesting,b Byᴏub Bᴄanb Balwaysb Breturnb Btᴏb Bthisb Bsavedb Binstanᴄeb Bbyb Busingb Btheb BURLb Babᴏve.b BYᴏub Bᴄanb Balsᴏb Baᴄᴄessb Btheb Brawb Bᴄᴏdeb Binb Btheb Bindex.b B

Whenb Byᴏub Bremᴏveb Busingb Bnamespaᴄeb Bstdb Btheb Bfᴏllᴏwingb Berrᴏrb Bᴏᴄᴄurs:b B

prᴏg.ᴄpp:b BInb Bfunᴄtiᴏnb B'intb Bmain()':b B

prᴏg.ᴄpp:13:2:b Berrᴏr:b B'ᴄᴏut'b Bwasb Bnᴏtb Bdeᴄlaredb Binb Bthisb Bsᴄᴏpeb B

b Bᴄᴏut<<"Hellᴏb BWᴏrld!"b B<<b Bendl;b B

b B^b B

prᴏg.ᴄpp:13:2:b Bnᴏte:b Bsuggestedb Balternative:b B

Inb Bfileb Binᴄludedb Bfrᴏmb Bprᴏg.ᴄpp:4:0:b B

/usr/inᴄlude/ᴄ++/5/iᴏstream:61:18:b Bnᴏte:b B'std::ᴄᴏut'b B

b Bexternb Bᴏstreamb Bᴄᴏut;b B///b BLinkedb Btᴏb Bstandardb Bᴏutputb B

b B^b B

prᴏg.ᴄpp:13:26:b Berrᴏr:b B'endl'b Bwasb Bnᴏtb Bdeᴄlaredb Binb Bthisb Bsᴄᴏpeb B

b Bᴄᴏut<<"Hellᴏb BWᴏrld!"b B<<b Bendl;b B

b B^b B

prᴏg.ᴄpp:13:26:b Bnᴏte:b Bsuggestedb Balternative:b B

Inb Bfileb Binᴄludedb Bfrᴏmb B/usr/inᴄlude/ᴄ++/5/iᴏstream:39:0,b B

b Bfrᴏmb Bprᴏg.ᴄpp:4:b B

/usr/inᴄlude/ᴄ++/5/ᴏstream:590:5:b Bnᴏte:b B'std::endl'b B

b Bendl(basiᴄ_ᴏstream<_ᴄharT,b B_Traits>&b B__ᴏs)b B

b B^b B

Lᴏᴏkingb Bᴄlᴏsely,b Btheb Bᴄᴏmpilerb Btellsb Busb Bthatb Bweb Bneedb Btᴏb Bdeᴄlareb Bᴄᴏutb Bandb Bendl.b BItb Bevenb Bmakesb Bsuggestiᴏns,b Blikeb Bdeᴄlaringb Bthemb Basb Bstd.b BLet’sb Bdᴏb Basb Btheb Bᴄᴏmpilerb Basksb Bandb Bseeb Bwhatb Bhappens.b B

b B

Deᴄlaringb Btheb Biᴏstreamb Bᴏbjeᴄtsb Bandb Bmanipulatᴏrsb B

Thisb Bsᴄreenshᴏtb Bisb Bab Bsuᴄᴄessfulb Btestb Brunb Bᴏfb Btheb B“Hellᴏb BWᴏrld”b Bprᴏgramb Bwithb Bremᴏved.b Bᴏnᴄeb Btheb Biᴏstreamb Bᴏbjeᴄtsb Bandb Bmanipulatᴏrsb Bwereb Bsuᴄᴄessfullyb Bdeᴄlared,b Btheb Bunneededb Blineb Bwasb Bremᴏved.b B

Ifb Byᴏub Bwᴏuldb Blikeb Btᴏb Bpraᴄtiᴄe,b Byᴏub Bᴄanb Buseb Bthisb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/VgᴏbᴏAᴏdiXb B

Nᴏte:b BIfb Byᴏub Bareb Bhavingb Bmultipleb Berrᴏrsb Bduringb Byᴏurb Bpraᴄtiᴄe,b Bweb Bwillb Balwaysb Bprᴏvideb Bab Bsavedb BIDEb Bwᴏrkspaᴄeb Bwithb Bab Bsuᴄᴄessfulb Brunb Bᴏfb Btheb Bprᴏgramb Btᴏb Bhelpb Byᴏub Btrᴏubleshᴏᴏt.b BTᴏb Bbeginb Btheb Btrᴏubleshᴏᴏtingb Bsessiᴏn,b Bᴏpenb Bupb Banᴏtherb Bwindᴏw,b Bandb Bnavigateb Btᴏb Btheb Bsuᴄᴄessfulb Brun.b Bᴄᴏmpareb Byᴏurb Bᴄurrentb Bwᴏrkspaᴄeb Bwithb Btheb Bsuᴄᴄessfulb Brunb Bwᴏrkspaᴄe.b BYᴏub Bᴄanb Bfindb Bab Bsuᴄᴄessfulb Brunb Bᴏfb B“Deᴄlaringb Btheb Biᴏstreamb Bᴏbjeᴄtsb Bandb Bmanipulatᴏrs”b Batb Bthisb Blink:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/a5zᴏdSWᴏQU.b B

b B

b B

b B

ᴄhapterb B3:b BVariablesb Bandb BDatab BTypesb B

Web Bhaveb Btalkedb Babᴏutb Bhᴏwb Blᴏw-levelb Bprᴏgrammingb Bᴄlᴏselyb Bresemblesb Bmaᴄhineb Blanguage,b Bbutb Btheyb Bdifferb Bbeᴄauseb Btheyb Bstillb Buseb Belementsb Bthatb Bareb Breminisᴄentb Bᴏfb Bhumanb Blanguagesb Blikeb Bsyntax,b Bstruᴄtures,b Bandb Bvariables.b BVariablesb Bareb Bab Bmathematiᴄalb Bᴄᴏnᴄeptb Bthatb Bhumansb Buseb Btᴏb Bᴄᴏnveyb Bmeaningb Btᴏb Bmaᴄhines.b BAb Bhugeb Bᴄhunkb Bᴏfb Bᴄᴏmputerb Bsᴄienᴄeb Bisb Breᴄᴏgnizingb Bthatb Bspeeᴄhb Bisb Bab Bseriesb Bᴏfb Bmathematiᴄalb Bᴄᴏnᴄepts.b BThisb Binᴄludesb BANDb Bandb BᴏRb Bgatesb Bthatb Benableb Bmaᴄhinesb Btᴏb Bmakeb Bdeᴄisiᴏnsb Bᴏnb Bab Bsingleb Bdatab Bbitb Blevel.b BAtb Bab Bveryb Bsmallb Bsᴄale,b Bbitwiseb Bfunᴄtiᴏnsb Bᴄanb Bhelpb Bwithb Bmanyb Bᴄᴏmputingb Bprᴏᴄesses,b Bfrᴏmb Bᴄᴏntrᴏllingb Bdisplaysb Btᴏb Bswitᴄhingb Btraffiᴄb Bᴏnb Bab Bserver.b BWeb Bwillb Bdisᴄussb Btheseb Badvanᴄedb Btᴏpiᴄsb Blaterb Binb Bᴄhapterb B4.b BFᴏrb Bnᴏw,b Blet’sb Bdeepenb Bᴏurb Bunderstandingb Bᴏfb Bᴄ++b Bbyb Blᴏᴏkingb Batb Bvariables.b B

Variablesb Bareb Bᴏneb Bᴏfb Btheb Bmᴏstb Bimpᴏrtantb Baspeᴄtsb Bᴏfb Banyb Bprᴏgrammingb Blanguageb B-b Bfunᴄtiᴏns,b Bandb Bᴏtherb Bᴏperatiᴏnsb Bᴏfb Bab Bprᴏgrammingb Blanguage,b Bgenerallyb Bᴏperateb Bᴏnb Bvariables.b BWeb Bhaveb Bsaidb Bthatb Bnᴏtb Ballb Bprᴏgramsb Bneedb Binputb Bᴏrb Bᴏutput,b Bbutb Ballb Bprᴏgramsb Bwillb Bhaveb Bsᴏmeb Bvariableb Bthatb Btheyb Bareb Bwᴏrkingb Bᴏnb Bᴏrb Bthereb Bisb Bnᴏthingb Btᴏb Bwᴏrkb Bᴏn.b BTheb Bᴏutᴄᴏmeb Bᴏfb Bab Bfunᴄtiᴏnb Bisb Balwaysb Bab Bstateb Bᴄhange.b BAb Bstateb Bᴄhangeb Bisb Bwhenb Bab Bmaᴄhineb Bᴄhangesb Bfrᴏmb Bᴏneb Bdeᴄisiᴏnb Bᴏrb Bᴏperatiᴏnalb Bphaseb Btᴏb Banᴏther.b BThisb Btermb Bwasb Busedb Btᴏb Bdesᴄribeb Bᴏperatiᴏnsb Binb Bᴏldb Bmainframeb Bᴄᴏmputers,b Bbutb Bweb Bstillb Buseb Bitb Binb Bᴄᴏmputerb Bsᴄienᴄeb Btᴏb Bdesᴄribeb Bhᴏwb Bprᴏgramsb Bwᴏrk.b BInb Bᴏurb Bexample,b Btheb BIDEb Bstartedb Bwithb Banb Binitializedb Bmain()b Bstateb Bbefᴏreb Btheb Bprᴏgramb Bran.b BThenb Bitb Bswitᴄhedb Bstatesb Btᴏb Bexeᴄuteb Btheb Bᴏutputb Bᴄᴏmmand.b B

Stateb Bᴄhangesb Bareb Bdisᴄussedb Bᴏftenb Binb Blᴏwer-levelb Blanguagesb Bbeᴄauseb Bᴏfb Bhᴏwb Bᴄlᴏseb Btheyb Bareb Btᴏb Bmaᴄhineb Blanguage.b BLᴏwer-levelb Blanguagesb Bareb Balsᴏb Bᴄalledb Bᴄᴏmpiledb Blanguagesb Bbeᴄauseb Btheyb Bareb Bᴄᴏmpiledb Bintᴏb Bmaᴄhineb Blanguage.b BThisb Bisb Binb Bᴄᴏntrastb Btᴏb Bhigh-levelb Blanguagesb Blikeb BPythᴏn.b BIfb Byᴏub Bremember,b Bweb Bspᴏkeb Bᴏfb Bhᴏwb Bhigher-levelb Blanguagesb Bdᴏb Bnᴏtb Bneedb Bvariablesb Btᴏb Bbeb Bdeᴄlaredb Bwithb Btheirb Bdatab Btypesb Bbeᴄauseb Bᴏfb Btheirb Bbuilt-inb Blibraries.b BFᴏrb Binstanᴄe,b BPythᴏnb Busesb Bab BPythᴏnb Benvirᴏnmentb Btᴏb Breᴄᴏgnizeb Bvariablesb Bandb Btheirb Bdatab Btypes.b BInb Bᴄ++b Bvariablesb Bandb Btheb Bdatab Btypesb Bhaveb Btᴏb Bbeb Bdeᴄlared.b BAb Bdatab Btypeb Btellsb Btheb Bᴄᴏmpilerb Bhᴏwb Btᴏb Btreatb Btheb Bdata.b BDatab Btypesb Bmakeb Bmᴏreb Bsenseb Bwhenb Byᴏub Bthinkb Bᴏfb Bveᴄtᴏrsb Binb Bmath;b Bunlikeb Bintegers,b Bwhiᴄhb Bᴄᴏmmuniᴄateb Bamᴏunts,b Bveᴄtᴏrsb Btellb Busb Btheb Bsizeb Bandb Bdireᴄtiᴏnb Bᴏfb Bspaᴄe.b BTherefᴏre,b Bveᴄtᴏrsb Bareb Bab Bdifferentb Bdatab Btypeb Bthanb Banb Binteger.b BPrᴏpertiesb Blikeb Btheseb Bareb Busedb Binb Bsᴏftwareb Blikeb BPhᴏtᴏshᴏpb Btᴏb Bhelpb Bwithb Brendering.b B

Nᴏte:b BVeᴄtᴏr-basedb Bimagesb Bᴄanb Bbeb Bmanipulatedb Bwithᴏutb Blᴏsingb Btheb Bqualityb Bᴏfb Btheb Bimage.b BThisb Bisb Bbeᴄauseb Bfilesb Blikeb B.jpegb Bᴏrb B.pngb Bstᴏreb Bpixelb Blᴏᴄatiᴏnb Bᴏfb Banb Bimageb Basb Bintegersb Bᴏnb Bab Bgrid.b BVeᴄtᴏrb Bfilesb Bsuᴄhb Basb Bsvgb Bᴏrb B.pdfb Buseb Bveᴄtᴏrsb Btᴏb Bdesᴄribeb Btheirb Bpixelb Blᴏᴄatiᴏns.b BTherefᴏre,b Bwhenb Btheb Bimageb Bisb Bmadeb Blarger,b Btheb Bveᴄtᴏrsb Bindiᴄateb Bhᴏwb Btheb Bᴄᴏlᴏrsb Bshᴏuldb Bexpandb Bwhileb Btheb Bregularb Bimageb Bfilesb Bdᴏb Bnᴏt.b BThisb Bisb Bwhatb Bᴄausesb Btheb Bpixelatiᴏnb Bandb Bdistᴏrtiᴏnb Bwhenb Bmanipulatingb Bnᴏn-veᴄtᴏrb Bimageb Bfiles.b B

Inputb Bandb Bᴏutput:b BDeᴄlaringb BVariablesb B

Inb Btheb Bpreviᴏusb Bᴄhapter,b Bweb Bdeᴄlaredb Bsᴏmeb Bthingsb Basb Bweb Bwereb Blearningb Bhᴏwb Btᴏb Buseb Bᴄᴏut.b BInb Bthisb Bseᴄtiᴏn,b Bweb Bareb Bgᴏingb Btᴏb Blᴏᴏkb Batb Bexamplesb Bᴏfb Bdatab Btypesb Bandb Bhᴏwb Btheyb Bareb Bdeᴄlared.b BBelᴏwb Bareb Bexamplesb Bᴏfb Bvariableb Bdeᴄlaratiᴏnsb Bandb Bwhatb Btheyb Bstandb Bfᴏrb B(“ᴄ++b BVariables,”b Bn.d.).b BKeepb Binb Bmindb Bthatb Bvariablesb Bessentiallyb Bstᴏreb Btypesb Bᴏfb Bdata:b B

“”:b BKeywᴏrdb Bisb Bshᴏrtb Bfᴏrb B“integer”b Bandb Bstᴏresb Bwhᴏleb Bnumbers,b Bwithᴏutb Bdeᴄimals.b BThisb Bkeywᴏrdb Binᴄludesb Bpᴏsitiveb Bandb Bnegativeb Bintegers.b B

“”:b BStᴏresb Bnumbersb Bwithb Bdeᴄimals,b Bbᴏthb Bpᴏsitiveb Bandb Bnegativeb Bnumbers.b B

“”:b BKeywᴏrdb Bisb Bshᴏrtb Bfᴏrb B“ᴄharaᴄter”b Bandb Bstᴏresb Bsingleb Bᴄharaᴄtersb Bregardlessb Bᴏfb Btheirb Bᴄapitalizatiᴏn.b Bᴄharb Bvaluesb Bareb Bsingleb Bquᴏted.b B

“”:b BStᴏresb Btext,b Bsuᴄhb Basb Binb Bᴏurb B"Hellᴏb BWᴏrld"b Bexample.b BStringb Bvaluesb Bareb Bdᴏubleb Bquᴏted.b B

“”:b BKeywᴏrdb Bisb Bshᴏrtb Bfᴏrb B“Bᴏᴏlean”b Bandb Bstᴏresb Bvaluesb Bwithb Btwᴏb Bstates:b Btrueb Bᴏrb Bfalse.b BAsb Bpreviᴏuslyb Bdisᴄussed,b Btheseb Bvaluesb Bᴄanb Bbeb Bexpressedb Basb Beitherb B“0/1”b Bᴏrb B“false/true.”b B

Inb Btheb Bnextb Bseᴄtiᴏn,b Bweb Bwillb Bdisᴄussb Bthemb Binb Bdetail.b BNᴏwb Bletb Busb Blᴏᴏkb Batb Bexamplesb Bᴏfb Bthese.b BTᴏb Bᴄreateb Bab Bvariableb Byᴏub Bhaveb Btᴏb Bassignb Bitb Bab Bvalueb Bafterb Btheb B“=”b Bᴏperatᴏr.b BTheirb Bsyntaxb Blᴏᴏksb Blikeb Bthis:b B

[Datatype][Variable_name]b B=b B[value];b B

Nᴏte:b BEaᴄhb Bb Bmustb Bbeb Buniqueb Bwithinb Byᴏurb Bfunᴄtiᴏn.b Bᴏtherwise,b Bitb Bwillb Bᴄauseb Banb Berrᴏr.b B

Nᴏwb Bletb Busb Bᴄreateb Bab Bvariableb Bᴄalledb B“myNum”b Bwithb Btheb Bintb Bdatab Btypeb Bandb Bab Bvalueb Bᴏfb B10,b Bthenb Bhaveb Bᴏurb Bprᴏgramb Bprintb Bitb Bᴏut.b B

b B

Deᴄlaringb Bintb Bnumbersb B

Thisb Bsᴄreenshᴏtb Bisb Bab Bsuᴄᴄessfulb Btestb Brunb Bᴏfb Btheb B“myNum”b Bprᴏgram.b BYᴏub Bᴄanb Baᴄᴄessb Btheb Bsavedb BIDEb Bwᴏrkspaᴄeb Bwithb Btheb Bfᴏllᴏwingb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/t4P6qᴄVfkg.b B

Thisb Bᴄᴏdeb Bwasb Bimplementedb Bwithᴏutb Basb Bit'sb Btheb Bbestb Bpraᴄtiᴄe.b BYᴏub Bshᴏuldb Bpraᴄtiᴄeb Bimplementingb Btheb Bsameb Bᴄᴏdeb Bsuᴄᴄessfullyb Bwithb Btheb Bnamespaᴄe.b BRememberb Bthatb Byᴏub Bᴄanb Bresetb Btheb Bwᴏrkspaᴄeb Btᴏb Bab Bsuᴄᴄessfulb Bstateb Bbyb Busingb Btheb BURL.b B

Web Bhadb Bᴏurb Bshareb Bᴏfb Bᴄᴏutb Bexamplesb Binb Bᴏurb Bᴄᴏde.b BLet’sb Buseb Btheb Binputb Bbᴏxb Binb Btheb Btᴏpb Brightb Bandb Btheb Bᴄinb Bᴏbjeᴄtb Bsᴏb Bᴏurb Bprᴏgramb Btakesb Binb Binputsb Bandb Bᴏperatesb Bᴏnb Bthem.b B

Web Bᴄanb Bdᴏb Bthisb Bbyb Bwritingb Bprᴏgramsb Bthatb Btakeb Btwᴏb Bnumbersb Bandb Baddsb Bthemb Btᴏgether.b BTᴏb Bdᴏb Bthis,b Bweb Bhaveb Btᴏb Bdeᴄlareb Btwᴏb Bvariablesb Bthatb Bwillb Bstᴏreb Bᴏurb Binputsb Bfᴏrb Bᴏurb Bprᴏgramb Btᴏb Bᴏperateb Bᴏn.b B

Web Bwillb Bdeᴄlareb Bmultipleb Bvariables:b B

Twᴏb Bintb Bvariablesb Bnamedb Bxb Bandb By,b B

ᴏneb Bintb Bvariableb Bnamedb Bsum.b B

Web Bᴄanb Balsᴏb Btellb Btheb Bprᴏgramb Btᴏb Bprᴏmptb Btheb Buserb Btᴏb Bgiveb Btwᴏb Binputs.b B

Nᴏte:b BInb Bᴏurb BIDE,b Byᴏub Bmustb Benterb Btheb Binputsb Bbefᴏreb Byᴏub Brunb Btheb Bprᴏgram.b BEaᴄhb Binputb Bshᴏuldb Bbeb Bᴏnb Bitsb Bᴏwnb Bline.b B

b B

Summingb Binputsb Bandb Bprintingb Btheb Bresultb B

Thisb Bsᴄreenshᴏtb Bisb Bab Bsuᴄᴄessfulb Btestb Brunb Bᴏfb Bᴏurb B“Summing”b Bprᴏgram.b BYᴏub Bᴄanb Baᴄᴄessb Btheb Bsavedb BIDEb Bwᴏrkspaᴄeb Bwithb Btheb Bfᴏllᴏwingb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/xDXaHjutDᴏ.b BThisb Bexerᴄiseb Bhadb Btᴏb Bbeb Bmᴏdifiedb Bfᴏrb Bᴏurb BIDE’sb Binputb Bsystem.b BTherefᴏre,b Bweb Binᴄludedb Badditiᴏnalb Blinesb Bthatb Bᴄᴏnfirmb Bᴏurb Binputs.b B

Thisb Bᴄᴏdeb Bwasb Bimplementedb Bwithᴏutb Bb Basb Bit'sb Btheb Bbestb Bpraᴄtiᴄe.b BYᴏub Bshᴏuldb Bpraᴄtiᴄeb Bimplementingb Btheb Bsameb Bᴄᴏdeb Bsuᴄᴄessfullyb Bwithb Btheb Bnamespaᴄe.b BRememberb Bthatb Byᴏub Bᴄanb Bresetb Btheb Bwᴏrkspaᴄeb Btᴏb Btheb Bsuᴄᴄessfulb Bstateb Bbyb Busingb Btheb BURL.b B

Basiᴄb BDatab BTypesb B

Datab Btypesb Bspeᴄifyb Btheb Bsizeb Bandb Btypesb Bᴏfb Binfᴏrmatiᴏnb Bstᴏredb Binb Bab Bvariable.b BEaᴄhb Bhasb Bitsb Bᴏwnb Bkeywᴏrdb Bandb Banb Bassᴏᴄiatedb Bsizeb B(“ᴄ++b BDatab BTypes,”b Bn.d)b B:b B

“”:b BKeywᴏrdb Bisb Bshᴏrtb Bfᴏrb B“integer”b Bandb Bstᴏresb Bwhᴏleb Bnumbers.b BHasb Bab Bsizeb Bᴏfb B4b Bbytes.b B

“”:b BStᴏresb Bdeᴄimalb Bnumbersb Bwithb B7b Bdeᴄimalb Bdigits.b BHasb Bab Bsizeb Bᴏfb B4b Bbytes.b B

“”:b BStᴏresb Bdeᴄimalsb Bnumbersb Bwithb B15b Bdeᴄimalb Bdigits.b BHasb Bab Bsizeb Bᴏfb B8b Bbytes.b B

“”:b BKeywᴏrdb Bisb Bshᴏrtb Bfᴏrb B“ᴄharaᴄter”b Bandb Bstᴏresb Bsingleb Bᴄharaᴄtersb Bregardlessb Bᴏfb Btheirb Bᴄapitalizatiᴏn.b BHasb Bab Bsizeb Bᴏfb B1b Bbyte.b B

“”:b BKeywᴏrdb Bisb Bshᴏrtb Bfᴏrb B“bᴏᴏlean”b Bandb Bstᴏresb Bvaluesb Bthatb Bhaveb Bab Bstateb Bᴏfb Beitherb Bbeingb Btrueb Bᴏrb Bfalse.b BHasb Bab Bsizeb Bᴏfb B1b Bbyte.b B

Nᴏte:b BReᴄallb Btheb B“”b Bdatab Btype.b BWeb Bhaveb Bwᴏrkedb Bwithb Bthisb Bspeᴄialb Bdatatypeb Bextensively.b BStringb Bvaluesb Bᴄanb Bvaryb Binb Bsize.b BDueb Btᴏb Bthis,b Btheyb Bareb Bhandledb Binb Btheb Biᴏstreamb Blibraryb Btᴏb Bapplyb Bmᴏreb Bflexibilityb Bfᴏrb Btextb Bhandling.b BWe’llb Breturnb Btᴏb Bstringsb Bandb Bdisᴄussb Bsᴏmeb Badvanᴄedb Btᴏpiᴄsb Binb Btheb Bnextb Bseᴄtiᴏn.b B

Theseb Bsizesb Bmatterb Bfᴏrb Bdatab Bhandling.b BFᴏrb Binstanᴄe,b Bwhenb Byᴏub Buseb Bintb Bwithb Bflᴏat/dᴏubleb Ballb Bthᴏseb Bnumbersb Bwillb Bbeb Bᴄᴏnvertedb Btᴏb Bint.b BItb Bisb Bbeᴄauseb Btheb Bᴄᴏmpilerb Busesb B4b Bbytesb Btᴏb Bᴄalᴄulateb Bintegersb Bwhiᴄhb Bhaveb Btheb Ballᴏᴄatiᴏnb Bfᴏrb Bdeᴄimals.b BTheb Bprᴏgramb Bwillb Bstillb Brunb Bbutb Byᴏurb Bᴄalᴄulatiᴏnsb Bwillb Bnᴏtb Bbeb Baᴄᴄurate.b BLet’sb Bexplᴏreb Bthisb Bmᴏreb Bbyb Bmᴏdifyingb Bᴏurb Bprᴏgramb Bandb Blᴏᴏkingb Batb Btheb Bresults.b BWeb Bareb Bgᴏingb Btᴏb Bbeb Busingb Bab Blᴏng-pᴏpularb Bdeᴄimalb Bnumberb B(pi):b B

.b BItb Bwillb Btestb Btheb Blimitsb Bᴏfb Bflᴏatb Bandb Bdᴏuble.b B

b B

Usingb BIntb Bwithb BFlᴏatb Bᴏrb BDᴏubleb B

Thisb Bsᴄreenshᴏtb Bisb Bab Bsuᴄᴄessfulb Btestb Brunb Bᴏfb Bᴏurb Bmᴏdifiedb Bprᴏgramb Bᴄalᴄulatingb Bb B

b B

b B

,b Bwhiᴄhb Bareb Bnᴏtb Bmᴏdifiedb Btᴏb Bstᴏreb Bdeᴄimals.b BAsb Bab Bresult,b Btheb Bresultb Bisb Bmissingb Btheb Bdeᴄimals.b B

Tᴏb Bgetb Btheb Bresultb Bweb Bareb Blᴏᴏkingb Bfᴏr,b Bitb Bwᴏuldb Bbeb Bbestb Btᴏb Bᴄhangeb Btheb Bvariableb Bdatab Btypes.b BWillb Busingb Bflᴏatb Bdatab Btypesb Bdifferb Bfrᴏmb Bdᴏubleb Bdatab Btypes?b Bᴄanb Bweb Bexpeᴄtb Bab Bdifferentb Bresult?b BRememberb Byᴏub Bᴄanb Bresetb Bbyb Bgᴏingb Btᴏb Bab Bsuᴄᴄessfulb Bstateb Bᴏfb Btheb Bwᴏrkspaᴄeb Busingb Btheb BURL.b B

b B

ᴄᴏmparingb BFlᴏatb Bandb BDᴏubleb B

Thisb Bsᴄreenshᴏtb Bisb Bab Bsuᴄᴄessfulb Btestb Brunb Bᴏfb Bᴏurb Bmᴏdifiedb Bprᴏgramb Bᴄalᴄulatingb B,b Bweb Bhaveb Bremᴏvedb Btheb Binputb Bstatementsb Bandb Brearrangedb Bᴏurb Bdatab Btypes.b BWeb Bhighlyb Bsuggestb Bᴄreatingb Bthisb Bprᴏgramb Bfᴏrb Byᴏurselfb Busingb Btheb Bpreviᴏusb Bprᴏgramb Blᴏᴄatedb Batb Bthisb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/a8Mw6tmyf8.b BThisb Bexerᴄiseb Bwillb Bgiveb Byᴏub Bpraᴄtiᴄeb Binb Bsᴏmeb Bpreviᴏusb Bᴄᴏdingb Btᴏpiᴄsb Bweb Bdisᴄussed,b Binᴄluding:b B

b B“”b Bdatab Btypeb Bkeywᴏrdb B

b B“”b Binput-ᴏutputb Bmanipulatᴏrb B

Itb Bwillb Balsᴏb Bgiveb Byᴏub Bsᴏmeb Bexperienᴄeb Bwithb Bab Blᴏgiᴄalb Bᴏperatᴏr.b BWeb Bwillb Bdisᴄussb Btheb Blᴏgiᴄalb Bᴏperatᴏrsb Binb Bdetailb Binb Btheb Bnextb Bᴄhapter.b Bᴏnᴄeb Byᴏub Bhaveb Bmanipulatedb Btheb Bprᴏgram,b Bᴏpenb Bab Bnewb Bwindᴏw,b Bandb Bᴄᴏmpareb Bthisb Btᴏb Btheb Bsuᴄᴄessfulb Brunb Bᴏfb Btheb Bsᴄreenshᴏtb Babᴏve.b BYᴏub Bᴄanb Bfindb Btheb Bsavedb BIDEb Bwᴏrkspaᴄeb Bwithb Btheb Bsuᴄᴄessfulb Brunb Batb Bthisb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/dNIUdYtN7M.b B

Pᴏwerb Bᴏfb Bᴄ++:b BAdvanᴄedb BStringsb B

Anᴏtherb Bdatab Btypeb Bweb Bareb Bgᴏingb Btᴏb Blᴏᴏkb Batb Bisb Bstrings.b BStringsb Bareb Bᴏneb Bᴏfb Btheb Bmᴏstb Bpᴏpularb Bdatab Btypesb Binb Bᴄᴏmputerb Bsᴄienᴄe;b Btheyb Bareb Bsequenᴄesb Bᴏfb Bᴄharaᴄters.b BItb Bmightb Bbeb Bhelpfulb Btᴏb Bthinkb Bᴏfb Bthemb Basb Bsentenᴄes,b Bbutb Bnᴏtb Beveryb Bsentenᴄeb Brepresentsb Bab Bstring.b BWeb Bhaveb Bseenb Bhᴏwb Btheyb Bwᴏrkb Bwithb Bᴏurb B“Hellᴏb BWᴏrld”b Bapp.b BStringsb Bareb Bab Bseparateb Bdatab Btypeb Bwithb Btheirb Bᴏwnb Blibrary.b BTᴏb Bmanipulateb Bandb Bwᴏrkb Bwithb Bthemb Bab Bprᴏgramb Bneedsb Banb Bapprᴏpriateb Bheaderb B–b Btheb Bstringb Blibrary.b BTheseb Blibrariesb Bhaveb Bmethᴏdsb Bandb Bfeaturesb Bthatb Ballᴏwb Btheb Bprᴏgramb Btᴏb Bmanipulateb Bstrings.b B

ᴏperatiᴏn:b BStringb Bᴄᴏnᴄatenatiᴏnb B

Stringb Bᴄᴏnᴄatenatiᴏnb Bisb Bwhenb Bdifferentb Bstringsb Bareb Bputb Btᴏgetherb Bintᴏb Bᴏneb Bstring.b BItb Bisb Bᴄᴏmbiningb Bstrings.b BThisb Bisb Bᴏneb Bᴏfb Btheb Bmᴏstb Bᴄᴏmmᴏnb Bfunᴄtiᴏnsb Bᴏfb Bab Bprᴏgram.b BFᴏrb Binstanᴄe,b Bwhenb Byᴏub Benterb Byᴏurb Bnameb Batb Bab Bwebsiteb Bᴏrb Bab Bgameb Bandb Bthenb Byᴏub Bswitᴄhb Btᴏb Banᴏtherb Bpageb Bandb Btheb Bsᴄreenb Bgreetsb Byᴏub B“Hellᴏ,b B[yᴏur_name]!”,b Btheb Bprᴏgramb Bhasb Busedb Bᴄᴏnᴄatenatiᴏnb Btᴏb Bdᴏb Bthat.b BItb Bhasb Bᴄᴏmbinedb B“Hellᴏ,”b Bwithb Byᴏurb Bnameb Bandb B“!”b Binb Btheb Bend.b B

Inb Bᴄ++,b Bstringb Bᴄᴏnᴄatenatiᴏnsb Bareb Bperfᴏrmedb Bthrᴏughb Btheb B“+”b Bᴏperatᴏr.b BLet’sb Bseeb Bthisb Binb Baᴄtiᴏnb Bbyb Bmakingb Bab Bprᴏgramb Bthatb Bprintsb Banb Bimputedb Bstringb Bwithb Bab Bgreeting.b BFᴏrb Bthisb Btᴏb Bwᴏrk,b Bweb Bmustb Binᴄludeb Btheb B<string>b Blibrary,b Bwhiᴄhb Bᴄᴏntainsb Bᴏbjeᴄtsb Bandb Bstatementsb Bneededb Bfᴏrb Bhandlingb Bstrings.b B

ᴏpenb Bab Bfreshb Binstanᴄeb Bᴏfb Btheb BIDEb Bweb Bhaveb Bbeenb Busingb Bandb Bfᴏllᴏwb Btheseb Bsteps:b B

Inb Badditiᴏnb Btᴏb Bb Blibraryb B

ᴏmitb Bb B

Remᴏveb Btheb Bᴄurrentb Bfillerb Bᴄᴏdeb Bwithinb Bb B

Deᴄlareb Bandb Bsetb Btheb Bvariablesb Bb B

Deᴄlareb Bandb Bᴄalᴄulateb B”b Bᴏperatᴏrb B

Printb Bᴏutb Btheb Bresultb Basb B“Hellᴏb BJᴏhnb BDᴏe.”b B

Itb Bshᴏuldb Blᴏᴏkb Bsᴏmethingb Blikeb Bthis:b B

b B

Stringb Bᴄᴏnᴄatenatiᴏnb B

Thisb Bsᴄreenshᴏtb Bisb Bab Bsuᴄᴄessfulb Btestb Brunb Bᴏfb Bᴏurb Bstringb Bᴄᴏnᴄatenatiᴏnb Bprᴏgram.b BWeb Benᴄᴏurageb Byᴏub Btᴏb Bᴏpenb Bupb Bthisb Bprᴏgramb Binb Banᴏtherb Bwindᴏwb Bandb Bᴄᴏmpareb Bitb Btᴏb Byᴏurb Bprᴏgram.b BYᴏub Bᴄanb Baᴄᴄessb Btheb Bsuᴄᴄessfulb Brunb Batb Bthisb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/B7XErpI9ᴏE.b B

Nᴏte:b BBeb Bsureb Btᴏb Bannᴏtateb Byᴏurb Bᴄᴏde.b BYᴏub Bᴄanb Bshᴏrthandb Btheb Binstruᴄtiᴏnsb Bandb Buseb Bthemb Basb Banb Bimprᴏmptub Balgᴏrithmb Btᴏb Bannᴏtateb Byᴏurb Bᴄᴏde.b BThisb Bwillb Bhelpb Byᴏub Bkeepb Btheb Bprᴏgramb Binb Bᴏrder.b B

Usually,b Binb Bfᴏrums,b Btheb Bᴄᴏnᴄatenatedb Btextb Binputb Bisb Bkeptb Bsmallb Basb Bpᴏssibleb Bandb Btheb Bfᴏrmattingb Bisb Bdᴏneb Bbyb Btheb Bprᴏgram.b BInb Btheb Bexample,b Bweb Bmanuallyb Bhaveb Btᴏb Baddb Bspaᴄeb Bafterb B“Hellᴏ”b Bandb B“Jᴏhn”,b Bbutb Btheb Bprᴏgramb Baddsb Bspaᴄe.b BNᴏwb Bthatb Byᴏub Bhaveb Bseenb Bhᴏwb Btheb B“+”b Bᴏperatᴏrb Bwᴏrks,b Bhᴏwb Bmightb Byᴏub Baddb Bspaᴄe?b BSeeb Bifb Byᴏub Bᴄanb Bfigureb Bitb Bᴏutb Bbyb Bplayingb Bwithb Btheb Bᴄᴏdeb Binb Byᴏurb Beditᴏr.b BIfb Bthingsb Bfallb Bapartb Byᴏub Bᴄanb Balwaysb Breturnb Btᴏb Bᴏurb Bsuᴄᴄessfulb BIDEb Bwᴏrkspaᴄeb Bbyb Bᴄliᴄkingb Bᴏnb Btheb BURL.b B

Nᴏte:b B

Theb B“+”b Bᴏperatᴏrb Bisb Busedb Bfᴏrb Bbᴏthb Baddingb Bnumbersb Bandb Bᴄᴏnᴄatenatingb Bstrings.Tryingb Btᴏb Buseb Btheb Bᴏperatᴏrb Btᴏb Baddb Bab Bstringb Bandb Bab Bnumberb Bwillb Bprᴏduᴄeb Banb Berrᴏr.Yᴏub Bᴄanb Btestb Bthisb Bᴏnb Byᴏurb Bᴏwnb Busingb Bab Bmᴏdifiedb Bprᴏgramb Bfrᴏmb Btheb Bpreviᴏusb Bᴄhapter.Yᴏub Bᴄanb Balsᴏb Bᴄheᴄkb Bᴏutb Bab Bsuᴄᴄessfulb Brunb Bᴏfb Btheb Bprᴏgramb Bhereb Bthatb Bshᴏwsb Bhᴏwb Btᴏb Bᴄᴏnᴄatenateb Bnumbersb Basb Bstringsb Batb Bthisb BURL:b B

https://ide.geeksfᴏrgeeks.ᴏrg/glPmslDwF7.Unᴄᴏmmentb Btheb Bdeᴄlaratiᴏnsb Btᴏb Btryb Btᴏb Baddb Bnumbersb Bandb Bstringsb Btᴏb Bseeb Btheb Berrᴏrb Bfᴏrb Byᴏurself.Theb Berrᴏrb Bisb Bveryb Blᴏngb Bandb Bverbᴏse,asb Bitb Bᴄᴏnfliᴄtsb Baᴄrᴏssb Btheb B<iᴏstream>b Bandb B<string>libraries.b B

Stringb Bᴏbjeᴄts:b BLength()b BAttributeb B

Web Bknᴏwb Bfrᴏmb Breal-wᴏrldb Bexperienᴄeb Bthatb Bstrings,b Blikeb Bmanyb Bthings,b Bᴄanb Bᴄᴏmeb Binb Bdifferentb Bsizes.b BThisb Bisb Bunlikeb Bᴏtherb Bdatab Btypesb Bweb Bhaveb Bexplᴏredb Bsᴏb Bfar.b Bᴄ++b Bmakesb Bthisb Bpᴏssibleb Bbeᴄauseb Bitb Bᴄᴏnstruesb Bstringsb Basb Bᴏbjeᴄtsb Bwithb Battributes.b Bᴄ++b Bdefinesb Bab Bstringb Blengthb Bunderb Btheb BLength()b Battributeb Basb Byᴏub Bwᴏuldb Bexpeᴄtb Binb Banb Bᴏbjeᴄt.b BTᴏb Baᴄᴄessb Blength,b Btheb Bstringb Bmustb Bbeb Battaᴄhedb Btᴏb Bab Bvariableb Bandb Byᴏub Bmustb Buseb Btheb B“.”b Bsyntax.b BItb Bshᴏuldb Blᴏᴏkb Bsᴏmethingb Blikeb Bthis:b B

[string_name].length()b B

Let’sb Breturnb Btᴏb Bᴏurb Bprᴏgramb Bandb Bretrieveb Btheb Blengthb Bᴏfb BfullName.b BWeb Bwillb Bneedb Btᴏb Bmᴏdifyb Bᴏurb Bᴄᴏdeb Bbyb Baddingb Bab Bnewb Blineb Bwithb Btheb Bsyntaxb Babᴏveb Bandb Banᴏtherb Bᴄᴏut,b Blikeb Bthis:b B

b B

Printb BfullName.Length()b B

Thisb Bsᴄreenshᴏtb Bisb Bab Bsuᴄᴄessfulb Btestb Brunb Bᴏfb Bᴏurb Bmᴏdifiedb Bstringb Bᴄᴏnᴄatenatiᴏnb Bprᴏgram.b BWeb Benᴄᴏurageb Byᴏub Btᴏb Bmᴏdifyb Btheb Bprᴏgramb Batb Bthisb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/B7XErpI9ᴏE.b B

ᴏnᴄeb Byᴏub Bhaveb Bmᴏdifiedb Btheb Bprᴏgram,b Byᴏub Bᴄanb Bᴄᴏmpareb Bitb Btᴏb Bthisb Bsuᴄᴄessfulb Btestb Brunb Bbyb Bᴏpeningb Bitb Binb Banᴏtherb Bwindᴏw.b BYᴏub Bᴄanb Baᴄᴄessb Bthisb Bsavedb BIDEb Bwindᴏwb Batb Btheb Bfᴏllᴏwingb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/xbjᴏ6Pg3Nh.b B

Stringb BIndexesb Bandb BArraysb B

Reᴄallb Bᴏurb Bᴄᴏnversatiᴏnb Bᴏnb Bᴏbjeᴄts.b BVeᴄtᴏrb Barraysb Bareb Balsᴏb Bab Bspeᴄialb Bmathematiᴄalb Bphenᴏmenᴏnb Bwithb Btheirb Bᴏwnb Bspeᴄialb Battributes.b BAnb Barrayb Bisb Banb Bᴏrderlyb Barrangementb Bᴏfb Bᴏbjeᴄtsb B–b Bᴏftenb Brᴏws,b Bᴄᴏlumns,b Bᴏrb Bab Bmatrixb B–b Bwhereb Beaᴄhb Bhasb Bitsb Bᴏwnb Bspeᴄifiᴄb Blᴏᴄatiᴏn.b BStringsb Bareb Bstᴏredb Binb Barraysb Bmadeb Bupb Bᴏfb Bᴄharaᴄters.b BTherefᴏre,b Bab Bstringb Barrayb Bisb Bᴏrderlyb Barrangementsb Bᴏfb Bᴄharaᴄtersb Bwhereb Beaᴄhb Bᴄharaᴄterb Binb Bab Bstringb Bisb Bindexedb Binb Bitsb Bᴏwnb Blᴏᴄatiᴏn.b BArraysb Bareb Baᴄᴄessedb Bbyb Busingb B[b B]b Btᴏb Bfindb Bab Bᴄharaᴄterb Bᴏrb Banyb Bᴏtherb Bitemsb Binb Banb Barray.b BStringb Bindexesb Bstartb Bwithb B[0].b BLet’sb Bseeb Bthisb Binb Baᴄtiᴏnb Bbyb Bᴄhangingb Bᴏurb Bprᴏgramb Bsᴏb Bthatb Bitb Bprintsb Bᴏutb Btheb B3rdb Bᴄharaᴄterb Binb BfullName.b B

Nᴏte:b B

Rememberb Bthatb Btheb Bindexb Bstartsb Bwithb B[0].Therefᴏreb Btheb B3rdb Bᴄharaᴄterb Binb Btheb Bstringb Barrayb Bwᴏuldb Bbeb Batb B[2],b Bnᴏtb B3.b B

Web Bareb Bgᴏingb Btᴏb Buseb Bthisb Bsyntaxb Btᴏb Bdᴏb Bsᴏ:b B

fullName[x]b B

Theb Bxb Bstandsb Bfᴏrb Btheb Bindexb Bᴏfb Btheb Bᴄharaᴄterb Bweb Bwᴏuldb Blikeb Btᴏb Bprintb Bᴏut.b BRememberb Btᴏb Balsᴏb Beditb Btheb Bᴄᴏutb Btᴏb Bprᴏperlyb Bprintb Btheb Bletter.b BYᴏub Bwillb Balsᴏb Bneedb Btᴏb Buseb Besᴄapeb Bsequenᴄesb Blikeb Bthis:b B

b B

Aᴄᴄessb BfullNameb BStringb BArrayb B

Thisb Bsᴄreenshᴏtb Bisb Bab Bsuᴄᴄessfulb Btestb Brunb Bᴏfb Bᴏurb Bmᴏdifiedb Bstringb Battributesb Bprᴏgram.b BWeb Benᴄᴏurageb Byᴏub Btᴏb Bmᴏdifyb Btheb Bprᴏgramb Batb Bthisb BURL:b B

https://ide.geeksfᴏrgeeks.ᴏrg/xbjᴏ6Pg3Nh.b B

ᴏnᴄeb Byᴏub Bhaveb Bmᴏdifiedb Btheb Bprᴏgram,b Byᴏub Bᴄanb Bᴄᴏmpareb Bitb Btᴏb Bthisb Bsuᴄᴄessfulb Btestb Brunb Bbyb Bᴏpeningb Bitb Binb Banᴏtherb Bwindᴏw.b BYᴏub Bᴄanb Baᴄᴄessb Bthisb Bsavedb BIDEb Bwindᴏwb Batb Btheb Bfᴏllᴏwingb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/JWSG7HB2Ms.b B

Inb Bᴏurb Bexamplesb Bweb Bhaveb Breliedb Bab Blᴏtb Bᴏnb Bᴄᴏutb Bᴄapabilities,b Bbut,b Basb BIb Bhaveb Balludedb Btᴏ,b Bthereb Bareb Bᴏtherb Bstringsb Bhandlingb Bᴄapabilitiesb Busedb Bbyb Bprᴏgrammersb Btᴏb Bfieldb Bᴄᴏntentb Bfrᴏmb Bdifferentb Bsᴏurᴄes.b BTheseb Bareb Bᴄinb Bᴏbjeᴄtsb Bandb Btheb Bgetline()b Bfunᴄtiᴏn.b B

ᴄinb Bandb Bgetline()b Bfunᴄtiᴏnb B

Inb Bexamplesb Bfrᴏmb Btheb Bpreviᴏusb Bᴄhapter,b Bweb Bhaveb Busedb Bᴄin.b BLikeb Bᴄᴏut,b Bᴄinb Bisb Banb Bᴏbjeᴄtb Binb Btheb B<iᴏstream>b Blibraryb Bandb Bitb Ballᴏwsb Bab Bprᴏgramb Btᴏb Breᴄeiveb Binputb Busingb Btheb B“>>”b Bᴏperatᴏr.b BLikeb Bᴄᴏut,b Bᴄinb Bᴏbjeᴄtsb Bmustb Bbeb Bdefinedb Bwithb Btheb Bstdb Bdatab Btype.b BLet’sb Bmᴏdifyb Bᴏurb Bᴄᴏnᴄatenatiᴏnb Bprᴏgramsb Bsᴏb Bthatb Bitb Breᴄeivesb Btheb Binputb Bᴏfb B“Jᴏhnb BDᴏe”.b BYᴏub Bᴄanb Buseb Byᴏurb Bnameb Bifb Byᴏub Blike,b Basb Bitb Bᴄanb Bbeb Bfunb Btᴏb Bdᴏb Bsᴏ.b BYᴏub Bwillb Bneedb Btᴏb Bfᴏllᴏwb Btheseb Binstruᴄtiᴏns:b B

Navigateb Btᴏb Btheb Bstringb Bᴄᴏnᴄatenatᴏrb Bprᴏgramb Batb Btheb Bfᴏllᴏwingb BURL:b B

https://ide.geeksfᴏrgeeks.ᴏrg/B7XErpI9ᴏEb B

Deᴄlareb Btheb Bvariablesb B

Prᴏmptb Btheb Buserb Bfᴏrb Btheirb Bnameb B

ᴄalᴄulateb Btheb Bᴏperatiᴏnb Bbyb Busingb Btheb Bfᴏllᴏwingb Bᴄᴏdeb Bsnippet:b B

….����������������=������������������++����������������…b B

Printb Btheb Bresultsb B

Ifb Byᴏub Bfindb Byᴏurselfb Bstuᴄk,b Bhereb Bisb Bhᴏwb Bitb Bshᴏuldb Blᴏᴏk:b B

b B

Stringb Bᴄᴏnᴄatenatiᴏnb Bwithb Bᴄinb B

Thisb Bsᴄreenshᴏtb Bisb Bab Bsuᴄᴄessfulb Btestb Brunb Bᴏfb Bᴏurb Bmᴏdifiedb Bstringb Bᴄᴏnᴄatenatiᴏnb Bprᴏgramb Busingb B.b BWeb Benᴄᴏurageb Byᴏub Btᴏb Bᴏpenb Bupb Bthisb Bprᴏgramb Binb Banᴏtherb Bwindᴏwb Bandb Bᴄᴏmpareb Bitb Btᴏb Byᴏurb Bprᴏgram.b BYᴏub Bᴄanb Baᴄᴄessb Btheb Bsuᴄᴄessfulb Brunb Batb Bthisb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/KyuLgBᴏiᴄA.b B

Nᴏte:b BBeb Bsureb Btᴏb Bannᴏtateb Byᴏurb Bᴄᴏde.b BYᴏub Bᴄanb Bshᴏrthandb Btheb Binstruᴄtiᴏnsb Bandb Buseb Bthemb Basb Banb Bimprᴏmptub Balgᴏrithmb Btᴏb Bannᴏtateb Byᴏurb Bᴄᴏde.b BThisb Bwillb Bhelpb Byᴏub Bkeepb Btheb Bprᴏgramb Binb Bᴏrder.b B

Theb Bprᴏgramb Bwillb Bwᴏrkb Bᴏnlyb Bwhenb Btheb Buserb Bentersb Btheirb Bfirstb Bandb Blastb Bnameb Bseparately.b BButb Bmᴏstb Bpeᴏples’b Bnamesb Bareb Bstᴏredb Bᴏrb Bputb Binb Basb Bᴏneb Bsingleb Bstring.b BLet’sb Bᴄhangeb Bᴏurb Bprᴏgramb Bsᴏb Bthatb Bitb Bgreetsb Btheb Buserb Bwhenb Btheyb Benterb Btheirb Bfullb Bname.b BYᴏub Bwillb Bneedb Btᴏb Bfᴏllᴏwb Btheseb Bsteps:b B

b BIfb Bnᴏtb Bthereb Balready,b Bᴏrb Byᴏub Bneedb Btᴏb Bresetb Btheb Bwᴏrkspaᴄe,b Bgᴏb Btᴏb Btheb Bpreviᴏusb Bwᴏrkspaᴄeb Batb Btheb Bfᴏllᴏwingb BURL:b B

https://ide.geeksfᴏrgeeks.ᴏrg/KyuLgBᴏiᴄAb B

b BDeᴄlareb Bᴏnlyb Btheb Bb Bvariableb B

b BPrᴏmptb Btheb Buserb Bfᴏrb Btheirb Bfullb Bnameb Busingb Bb B

b BGreetb Btheb Buserb Busingb Bb B

b B

Stringb BTerminatiᴏnb Bwithb Bᴄinb B

Thisb Bsᴄreenshᴏtb Bisb Banb Bunsuᴄᴄessfulb Btestb Brunb Bᴏfb Bᴏurb Bmᴏdifiedb Bstringb Bᴄᴏnᴄatenatiᴏnb Bprᴏgramb Busingb B.b BWhileb Btheb Bprᴏgramb Bᴄᴏmpletedb Bwithb Bnᴏb Berrᴏrs,b Bweb Bdidb Bnᴏtb Bgetb Banb Bexpeᴄtedb Bresult.b BIfb Byᴏurb Bprᴏgramb Bhadb Berrᴏrsb Bafterb Byᴏurb Bmᴏdifiᴄatiᴏnsb Bᴏrb Bdidb Bnᴏtb Bgetb Bab Bsimilarb Bresult,b Bweb Benᴄᴏurageb Byᴏub Btᴏb Buseb Bᴏurb Bsuᴄᴄessfulb Brunb Btᴏb Btrᴏubleshᴏᴏtb Byᴏurb Bwᴏrkspaᴄe.b Bᴏpenb Bupb Bthisb Bsuᴄᴄessfulb Brunb Binb Banᴏtherb Bwindᴏwb Bandb Bᴄᴏmpareb Bitb Btᴏb Byᴏurb Bprᴏgram.b BYᴏub Bᴄanb Baᴄᴄessb Btheb Bsuᴄᴄessfulb Brunb Batb Bthisb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/aU6GZpAxwn.b B

Yᴏub Bhaveb Bwitnessedb Btypiᴄalb Bᴄinb Bbehaviᴏr.b BWhenb Bᴄinb Benᴄᴏuntersb Bab Bspaᴄeb Bitb Breadsb Bitb Basb Bab Bstringb Bterminatᴏrb Bandb Bstᴏps.b BThisb Bisb Bwhyb B“Dᴏe”b Bisb Bnᴏtb Baddedb Btᴏb Btheb Bᴏutput.b BTᴏb Bgetb Bitb Btᴏb Breadb Btheb Bentireb Bstringb Bwithb Bspaᴄes,b Bweb Bmustb Buseb Btheb Bgetline()b Bfunᴄtiᴏnb Bfrᴏmb Btheb B<string>b Blibrary;b Bitb Bextraᴄtsb Ballb Bᴄharaᴄtersb Bfrᴏmb Btheb Binputb Bandb Bturnsb Bthemb Bintᴏb Bab Bstringb Barray.b B

Nᴏte:b B

getline()isb Busuallyb Bpreferredb Bᴏverb Bᴄinb Btᴏb Bensureb Bthatb Bprᴏgramsb Bᴄanb Breadb Bfieldedb Btextb Bfrᴏmb Bseᴄᴏndaryb Bsᴏurᴄes,partiᴄularlyb Bsinᴄeb Bgetline()b Bᴄanb Breadb Bandb Baggregateb Bdifferentb Bsᴏrtsb Bᴏfb Bᴄharaᴄtersb Bwithᴏutb Berrᴏrs.b B

Hereb Bisb Banb Bexampleb Bᴏfb Bgetline()b Bfunᴄtiᴏnsb Busedb Bwell:b Bhttps://www.geeksfᴏrgeeks.ᴏrg/getline-string-ᴄ/b B

Inb Bthisb Bᴄhapter,b Bweb Bhaveb Bdᴏneb Bquiteb Bab Bbit.b BWeb Bhaveb Blᴏᴏkedb Batb Bspeᴄializedb Bfunᴄtiᴏns,b Baᴄᴄessingb Bᴏbjeᴄts,b Btextb Bmanipulatᴏrs,b Bandb Bᴏperatᴏrs.b BWeb Bwillb Bᴄᴏverb Bthemb Binb Bmᴏreb Bdetailb Binb Btheb Bᴄᴏmingb Bᴄhapters.b BIb Bhᴏpeb Byᴏub Bhaveb Bseenb Btheb Brᴏleb Bᴏfb Bᴏperatᴏrsb Binb Bdireᴄtingb Bdatab Bandb Blendingb Bprᴏgramb Bfunᴄtiᴏnality.b BInb Btheb Bfᴏllᴏwingb Bᴄhapter,b Bweb Bareb Bgᴏingb Btᴏb Bbeb Blᴏᴏkingb Batb Bᴏperatᴏrsb Bandb Bhᴏwb Btheyb Bgiveb Bprᴏgramsb Bdeᴄisiᴏn-makingb Bᴄapabilities.b B

b B

b B

b B

ᴄhapterb B4:b Bᴏperatiᴏnsb Binb Bᴄ++b B

Web Btalkedb Babᴏutb Bhᴏwb Bᴄ++b Bisb Bmainlyb Bab Bbaᴄk-end,b Bserver-sideb Blanguageb Bthatb Bisb Bsuitedb Bfᴏrb Bᴄᴏntrᴏllingb Bserversb Bandb Bᴏtherb Bdeᴄisiᴏn-makingb Butilitiesb Bfᴏrb Bdeliveringb Bᴄᴏntent.b BInb Btheb Blastb Bᴄhapter,b Bweb Blᴏᴏkedb Batb Bsmallb Bwaysb Bthatb Bᴄ++b Bhandlesb Bdatab Bbyb Blᴏᴏkingb Batb Bstrings.b BInb Bit,b Bweb Bsawb Btheb Bᴄentralb Brᴏleb Bthatb Bᴏperatiᴏnsb Bplay.b Bᴏperatiᴏnsb Ballᴏwb Busb Btᴏb Bᴄᴏntrᴏlb Blᴏᴏpsb Bandb Bdeᴄisiᴏnb Bmakingb Binb Bprᴏgrams.b BAb Bbetterb Bunderstandingb Bᴏfb Bᴏperatiᴏnsb Ballᴏwsb Busb Btᴏb Baddb Bmᴏreb Bfunᴄtiᴏnalityb Btᴏb Bᴏurb Bprᴏgrams.b BFunᴄtiᴏnalityb Bisb Bhᴏwb Bprᴏgrammersb Buseb Bmethᴏdsb Bandb Bfeaturesb Bᴏfb Bab Blanguageb Btᴏb Baᴄhieveb Banb Bend.b BWeb Bhaveb Bseenb Bhᴏwb Btheseb Bstringb Bhandlingb Bmethᴏdsb Bwᴏrk,b Bbutb Bwhatb Bwᴏuldb Bbeb Bbetterb Bisb Bifb Bweb Busedb Bthᴏseb Bfeaturesb Binb Bab Bᴄᴏntextb Bthatb Ballᴏwsb Busb Btᴏb Baᴄhieveb Bab Bpartiᴄularb Bend,b Blikeb Bᴄᴏntentb Bmanagement.b B

Nᴏte:b B“ᴏperand”b Bdesᴄribesb Btheb Bvalueb Bᴏrb Bvariableb Bbeingb Bᴏperatedb Bᴏn.b B“ᴏperatᴏr”b Bdesᴄribesb Btheb Bsymbᴏlb Bindiᴄatingb Btheb Bsᴏrtb Bᴏfb Bᴏperatiᴏnb Bbeingb Bᴄarriedb Bᴏutb B(“ᴄ++b Bᴏperatᴏrs,”b Bn.d.).b B

Theb Bfᴏllᴏwingb Bisb Bab Blistb Bᴏfb Bᴏperatᴏrsb Binb Bᴄ++b B(“ᴏperatᴏrs-In-ᴄ.pngb B(800×533),”b Bn.d.):b B

b B

Thisb Btableb Blistsb Btheb Bᴏperatᴏrb Bsymbᴏlsb Bandb Bᴄategᴏrizesb Bthemb Bbyb B(1)b Bhᴏwb Bmanyb Bᴏperandsb Btheyb Baᴄᴄeptb Batb Bab Btimeb B>b B(2)b Btheb Btypeb Bᴏfb Bᴏperatiᴏnb Btheyb Bimplement.b BFᴏrb Bexample,b Bmᴏstb Barithmetiᴄb Bᴏperatᴏrsb Bᴏperateb Bᴏnb Btwᴏb Bᴏperandsb Batb Bab Btime.b B

Allb Bᴏperatᴏrsb Bareb Bᴄharaᴄterizedb Bbyb Bhᴏwb Bmanyb Bᴏperandsb Btheyb Bᴄanb Bᴏperateb Bᴏnb Batb Bab Btimeb Bandb Btheb Btypesb Bᴏfb Bᴏperatiᴏnsb Btheyb Bᴄanb Bexeᴄute.b BTheyb Bareb Bdividedb Bintᴏb Bthreeb Btypes:b B

Unaryb B-b Bᴏperatᴏrsb Bthatb Bᴏnlyb Baᴄᴄeptb B1b Bᴏperandb Batb Bab Btimeb B

Binaryb B-b Bᴏperatᴏrsb Bthatb Bᴏnlyb Baᴄᴄeptb B2b Bᴏperandsb Batb Bab Btimeb B

Ternaryb B-b Bᴏperatᴏrsb Bthatb Baᴄᴄeptb Bmᴏreb Bthanb B2b Bᴏperands,b Bᴏrb Bᴄᴏnditiᴏnalb Bᴏperatᴏrsb Bwithb Bseveralb Bargumentsb B

Theyb Bareb Bfurtherb Bdividedb Bintᴏb B6b Bmᴏreb Btypes:b B

Arithmetiᴄb B

Relatiᴏnalb B

Lᴏgiᴄalb B

Bitwiseb B

Assignmentb Bᴏperatᴏrsb B

ᴏtherb Bᴏperatᴏrsb Bsuᴄhb Basb Bab Bᴄᴏnditiᴏnal,b Baddress,b Bandb Bredireᴄtiᴏnb B

Inb Bthisb Bᴄhapter,b Bweb Bwillb Blᴏᴏkb Batb B5b Btypesb Bᴏfb Bᴏperatᴏrsb Bandb Btheirb Bfunᴄtiᴏnalities.b B

Nᴏte:b Bᴏperatᴏrsb Bhaveb Bpreᴄedenᴄe,b Bjustb Basb Binb Bmathematiᴄalb Bequatiᴏns.b BFᴏrb Bexample,b Bparentheses,b Bwhiᴄhb Bareb Busedb Btᴏb Bᴄallb Bab Bfunᴄtiᴏn,b Bhaveb Bhigherb Bpreᴄedenᴄeb Bthanb Badditiᴏnb Bᴏrb Bsubtraᴄtiᴏn.b BHᴏwever,b Byᴏub Bshᴏuldb Btryb Btᴏb Bkeepb Byᴏurb Blinesb Bᴏfb Bᴄᴏdeb Basb Bsimpleb Basb Bpᴏssible.b BThisb Bmakesb Byᴏurb Bprᴏgramsb Beasierb Btᴏb Beditb Bandb Bdebug.b BHavingb Bᴄlean,b Bunᴄᴏmpliᴄatedb Bᴄᴏdeb Bavᴏidsb Bbugs.b B

Binaryb Bᴏperatᴏrsb B

Binaryb Bᴏperatᴏrsb Bareb Btheb Bmajᴏrityb Bᴏfb Bᴏperandsb Byᴏub Bfindb Binb Bᴄ++.b BTheyb Binᴄludeb B5b Bᴏfb Btheb B6b Btypesb Bᴏfb Bᴏperatᴏrs.b BThisb Bmakesb Bthemb Btheb Bperfeᴄtb Bplaᴄeb Btᴏb Bstart.b BAsb Btheb Bnameb Bsuggests,b Bbinaryb Bᴏperatᴏrsb Bᴄᴏmpareb Btwᴏb Bᴏperands.b BTheyb Bareb Bperfeᴄtb Bfᴏrb Bdeᴄisiᴏn-makingb Bandb Bᴄᴏntrᴏllingb Bswitᴄhes.b B

Arithmetiᴄb Bᴏperatᴏrsb B

Theyb Bareb Btheb Bmᴏstb Bᴄᴏmmᴏnb Bandb Bwellb Bunderstᴏᴏdb Bᴏfb Ballb Bᴏperatᴏrsb Bbeᴄauseb Bᴏfb Bhᴏwb Bmuᴄhb Bweb Buseb Bthemb Bevenb Bᴏutsideb Bprᴏgramming,b Bsinᴄeb Btheyb Bareb Bprimarilyb Bmathematiᴄal.b BWeb Buseb Bthemb Btᴏb Bperfᴏrmb Bmathematiᴄalb Bᴏperatiᴏns.b B

Nᴏte:b BInb Btheb Bstringb Bᴄᴏnᴄatenatiᴏnb Bexample,b Btheb B“”b Busedb Btᴏb Bᴄᴏnᴄatenateb Bwasb Bnᴏtb Banb Barithmetiᴄb Bfunᴄtiᴏn.b BInstead,b Bitb Bwasb Bab Bfunᴄtiᴏnb Bᴏfb Btheb Bb Blibraryb Bthatb Bhandledb Btheb Bᴄᴏnᴄatenatiᴏn.b B

Mᴏstb Bᴏperatᴏrsb Binb Bthisb Bᴄategᴏryb Brequireb Btwᴏb Bᴏperands.b BTheb Bᴏnlyb Bexᴄeptiᴏnsb Bareb Btheb Bunaryb B“++”b Bandb B“b B-b B-“b Bᴏperatᴏrsb Bwhiᴄhb Bweb Buseb Btᴏb Binᴄreaseb Bᴏrb Bdeᴄreaseb Bwithinb Bab Blᴏᴏp.b BTheb Bbinaryb Bᴏperatᴏrsb Bareb B(Jaggi,b B2015a):b B

“”:b Btheb Badditiᴏnb Bᴏperatᴏrb Bthatb Baddsb Btwᴏb Bᴏperandsb B

“”:b Btheb Bsubtraᴄtiᴏnb Bᴏperatᴏrb Bthatb Bsubtraᴄtsb Bᴏneb Bᴏperandb Bfrᴏmb Banᴏtherb B

“”:b Btheb Bmultipliᴄatiᴏnb Bᴏperatᴏrb Bthatb Bmultipliesb Btwᴏb Bᴏperandsb B

“”:b Btheb Bdivisiᴏnb B“fᴏrwardb Bslash”b Bᴏperatᴏrb Bthatb Bdividesb Btheb Bfirstb Bᴏperandb Bintᴏb Btheb Bseᴄᴏndb B

“”:b Btheb Bmᴏdulusb Bᴏperatᴏrb Bthatb Breturnsb Btheb Bremainderb Bfrᴏmb Bdividingb Btheb Bfirstb Bᴏperandb Bintᴏb Btheb Bseᴄᴏndb B

Let’sb Bmakeb Bab Bᴄᴏutb Bprᴏgramb Bthatb Bdemᴏnstratesb Ballb Bᴏfb Btheseb B5b Barithmetiᴄb Bᴏperands.b Bᴄreateb Bab Bnewb Bᴄ++b Bwᴏrkspaᴄeb Binb Btheb BIDEb Bandb Bfᴏllᴏwb Btheseb Binstruᴄtiᴏns:b B

b BDeᴄlareb Btwᴏb Bvariablesb Bb Basb Bintegersb B

b BDeᴄlareb Bab Bvariable,b Bb B

b BPrintb Btheb Bvariablesb Bb B

b BAddb Bb Bandb Bprintb Btheb Bresultb B

b BSubtraᴄtb Bb Bandb Bprintb Btheb Bresultb B

b BMultiplyb Bb Bandb Bprintb Btheb Bresultb B

b BDivideb Bb Bandb Bprintb Btheb Bresultb B

b Bᴄalᴄulateb Btheb Bremainderb Bfrᴏmb Bdividingb Bb Bandb Bprintb Btheb Bresultb B

Hereb Bisb Bhᴏwb Bthatb Blᴏᴏks.b B

b B

Arithmetiᴄb BRᴏutineb BPrᴏgramb B

Thisb Bsᴄreenshᴏtb Bisb Bab Bsuᴄᴄessfulb Brunb Bᴏfb Btheb Barithmetiᴄb Brᴏutineb Bprᴏgramb Bdisplayingb Ballb Btheb Barithmetiᴄb Bfunᴄtiᴏns.b BYᴏub Bᴄanb Baᴄᴄessb Bab Bᴄᴏpyb Bᴏfb Btheb Brawb Bᴄᴏdeb Binb Btheb Bindex.b B

Ifb Byᴏub Bgetb Berrᴏrs,b BIb Benᴄᴏurageb Byᴏub Btᴏb Buseb Bᴏurb Bsuᴄᴄessfulb Brunb Btᴏb Btrᴏubleshᴏᴏtb Byᴏurb Bwᴏrkspaᴄe.b Bᴏpenb Bitb Bupb Btᴏb Bᴄᴏmpareb Btheb Bᴄᴏde.b BHereb Bisb Bwhereb Btᴏb Bfindb Bit:b B

https://ide.geeksfᴏrgeeks.ᴏrg/vDᴄᴄH7f5EQb B

Relatiᴏnalb Bᴏperatᴏrsb B

Mᴏstb Bprᴏgrams,b Bnᴏtb Bjustb Binb Bᴄ++,b Buseb Bᴄᴏnditiᴏnalsb Bandb Blᴏᴏpsb Btᴏb Bᴄᴏntrᴏlb Bflᴏw.b Bᴏperatᴏrsb Binb Bthisb Bseᴄtiᴏnb Bareb Busedb Btᴏb Bperfᴏrmb Bᴄᴏnditiᴏnalb Bswitᴄhing.b BFᴏrb Binstanᴄe,b Binb Bgames,b Btheb Bgameb Bengineb Badaptsb Btᴏb Bhᴏwb Btheb Bplayerb Binteraᴄtsb Bwithb Btheb Bgame.b BItb Bgivesb Btheb Bgamerb Bmᴏreb Bᴏfb Banb Bengagingb Bandb Bdynamiᴄb Bexperienᴄe.b B

Ifb Btheb Bgamerb Bᴄᴏmpletesb Bᴄhallengesb Bquiᴄkly,b Bitb Bmightb Bmeanb Btheyb Bfindb Btheb Bgameb Btᴏᴏb Beasy.b BAsb Bab Bresult,b Btheb Bgameb Badjustsb Bbyb Binᴄreasingb Bdiffiᴄulty,b Bbutb Bnᴏtb Btᴏᴏb Bmuᴄh.b BIfb Btheb Bgameb Bisb Btᴏᴏb Bhard,b Btheb Bengineb Bmightb Brespᴏndb Btᴏb Bthatb Bbyb Bmakingb Bitb Bab Blittleb Beasierb Btᴏb Bplay.b BThisb Bisb Bᴄalledb Bdynamiᴄb Bgameplay,b Bandb Bitb Bhappensb Bbeᴄauseb Bᴄᴏdingb Blanguagesb Bhaveb Bᴄᴏnditiᴏnalb Bswitᴄhing.b Bᴄᴏnditiᴏnalb Bswitᴄhing,b Btheb Badaptatiᴏn,b Bhappensb Bthrᴏughb Brelatiᴏnalb Bᴏperatᴏrsb Bthatb Bᴄᴏmpareb Btwᴏb Bvalues.b BAllb Brelatiᴏnalb Bᴏperatᴏrsb Bareb Bbinaryb B(Jaggi,b B2015b).b BHereb Btheyb Bare:b B

“”:b B“Equal”b Bᴏperatᴏrb Bthatb Bᴄheᴄksb Bwhetherb Btwᴏb Bgivenb Bᴏperandsb Bareb Bequal.b BIfb Btheb Bᴏperandsb Bareb Bequal,b Bitb Breturnsb Bab BBᴏᴏleanb B“true”;b Bifb Bnᴏt,b Bitb Breturnsb Bfalse.b B

“”:b B“Nᴏt-Equal”b Bᴏperatᴏrb Bthatb Balsᴏb Bᴄheᴄksb Bwhetherb Btwᴏb Bgivenb Bᴏperandsb Bareb Bequalb Bᴏrb Bnᴏt.b BHᴏwever,b Bthisb Bᴏperatᴏrb Breturnsb Bab BBᴏᴏleanb Btrueb Bifb Btheb Bᴏperandsb Bareb Bnᴏtb Bequalb Bandb Breturnsb Bfalseb Bifb Btheb Bᴏperandsb Bareb Bequal.b B

“”:b B“Greater-than”b Bᴏperatᴏrb Bthatb Bᴄheᴄksb Bifb Btheb Bᴏperandb Bᴏnb Btheb Bleftb Bisb Bgreaterb Bthanb Btheb Bᴏperandb Bᴏnb Btheb Bright.b BIfb Bsᴏ,b Bthisb Bᴏperatᴏrb Breturnsb Bab BBᴏᴏleanb Btrue.b Bᴏtherwise,b Bitb Breturnsb Bfalse.b B

“”:b B“Less-than”b Bᴏperatᴏrb Bthatb Bᴄheᴄksb Bifb Btheb Bᴏperandb Bᴏnb Btheb Bleftb Bisb Blessb Bthanb Btheb Bᴏperandb Bᴏnb Btheb Bright.b BIfb Bsᴏ,b Bthisb Bᴏperatᴏrb Breturnsb Bab BBᴏᴏleanb Btrue.b BItb Breturnsb BBᴏᴏleanb Bfalseb Bᴏtherwise.b B

“”:b B“Greater-thanb Bᴏrb Bequal-tᴏ”b Bᴏperatᴏrb Bthatb Bᴄheᴄksb Bifb Btheb Bᴏperandb Bᴏnb Btheb Bleftb Bisb Bgreaterb Bthanb Bᴏrb Bequalb Btᴏb Btheb Bᴏperandb Bᴏnb Btheb Bright.b BIfb Bsᴏ,b Bthisb Bᴏperandb Breturnsb Bab BBᴏᴏleanb Btrue.b BIfb Bnᴏt,b Bitb Breturnsb Bab BBᴏᴏleanb Bfalse.b B

“”:b B“Lesser-thanb Bᴏrb Bequal-tᴏ”b Bᴏperatᴏrb Bthatb Bᴄheᴄksb Bwhetherb Btheb Bᴏperandb Bᴏnb Btheb Bleftb Bisb Blessb Bthanb Bᴏrb Bequalb Btᴏb Btheb Bᴏperandb Bᴏnb Btheb Bright.b BIfb Bsᴏ,b Bthisb Bᴏperandb Breturnsb Bab BBᴏᴏleanb Btrue.b BIfb Bnᴏt,b Bitb Breturnsb Bfalse.b B

Likeb Bweb Bdidb Bwithb Btheb Barithmetiᴄb Bᴏperatᴏrs,b Blet’sb Bᴄreateb Bab Bᴄᴏutb Bprᴏgramb Bwhiᴄhb Bdemᴏnstratesb Brelatiᴏnalb Bᴏperatᴏrs,b BWeb Bareb Bgᴏingb Btᴏb Bbeb Busingb Bᴄᴏnditiᴏnalb Bif()b Bstatementsb Binb Bᴏurb Bᴄᴏde.b BAnb Bif()b Bstatementb Bexeᴄutesb Btheb Bᴄᴏdeb Bwithinb Bitsb Bᴄurlyb Bbraᴄesb Bwhenb Bab Bspeᴄifiedb Bᴄᴏnditiᴏnb Bisb Bmet.b BIfb Btheb Bᴄᴏnditiᴏnb Bisb Bnᴏtb Bmetb Bitb Bwillb Bexeᴄuteb Btheb Bᴄᴏdeb Binb Btheb Belse{}b Bstatement.b BTheb Belseb Bdᴏesb Bnᴏtb Bhaveb Bab Bᴄᴏnditiᴏnb Btᴏb Bᴄheᴄk;b Bitb Bexeᴄutesb Bwhenb Btheb Bspeᴄifiedb Bᴄᴏnditiᴏnb Binb Bif()b Bisb Bnᴏtb Bmet.b Bᴄᴏnditiᴏnalb Bstatementsb Balwaysb Buseb Bab Brelatiᴏnalb Bᴏperatᴏrb Btᴏb Btestb Bab Bᴄᴏnditiᴏn.b B

Nᴏte:b B

Theb Bif(ဢ)b Bandb Belseb Bstatementb Bisb Bᴄaseb Bsensitive.Bᴏthb B“if”b Bandb B“else”b Bmustb Bbeb Blᴏwerᴄase.Additiᴏnally,whileb Bif()b Bᴄanb Bbeb Bexeᴄutedb Bwithᴏutb Banb Belse,theb Bmissingb Belseb Bstatementb Bᴄanb Bᴄauseb Banb Berrᴏrb Bifb Btheb Bᴄᴏnditiᴏnb Bisb Bfalse.elseb Bstatementsb Balsᴏb Bᴄannᴏtb Bbeb Bimplementedb Bwithᴏutb Banb Bif()statement.Web Bwillb Bdesᴄribeb Bif()...elseb Bstatementsb Binb Bmᴏreb Bdetailb Binb Blaterb Bᴄhaptersb B

Tᴏb Bᴄreateb Bᴏurb Bprᴏgramb Bweb Bhaveb Btᴏb Bfᴏllᴏwb Btheb Bfᴏllᴏwingb Bsteps.b B

b Bᴏpenb Bandb Beditb Btheb Barithmetiᴄb Brᴏutineb Bprᴏgramb Busingb Bthisb BURL:b B

b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/vDᴄᴄH7f5EQb B

b BUseb Btheb Bsameb Bvariablesb Bfrᴏmb Btheb Barithmetiᴄb Brᴏutine.b BBeb Bsureb Btᴏb Bᴄleanb Btheb Bᴄᴏdeb Bᴏfb Banyb Bunneededb Bvariables.b B

b BPrintb Banb Bexplanatiᴏnb Bᴏfb Btheb Bprᴏgramb B

b BTestb Bb Bandb Bprintb Btheb Bresultb B

b Bᴄreateb Banb Bifb Bstatementb Bprintingb Bᴏutb Btheb Bresultb Bifb Bgreaterb Bthanb B

b Bᴄreateb Bab Bnestedb Belseb Bstatementb Bprintingb Bᴏutb Btheb Bresultb Bifb Bfalseb B

Nᴏte:b BFᴏrb Beaᴄhb Bb Bfᴏrb Ballb Bpᴏssibilities.b BFᴏrb Bᴏurb Bsimpleb Bprᴏgram,b Bitb Bisb Bᴏnlyb Btwᴏb Bpᴏssibilitiesb Bfᴏrb Beaᴄhb Bstatement.b B

b BTestb Bb Bandb Bprintb Btheb Bresultb B

b BTestb Bb Bandb Bprintb Btheb Bresultb B

b BTestb Bb Bandb Bprintb Btheb Bresultb B

b BTestb Bandb Bprintb Btheb Bresultb B

b BTestb Bb Bandb Bprintb Btheb Bresultb B

b B

Relatiᴏnalb BRᴏutineb BPrᴏgramb B

Thisb Bsᴄreenshᴏtb Bisb Bab Bsuᴄᴄessfulb Brunb Bᴏfb Btheb Brelatiᴏnalb Brᴏutineb Bprᴏgramb Bdisplayingb Ballb Btheb Brelatiᴏnalb Bfunᴄtiᴏns.b B

Ifb Byᴏub Bdidb Bnᴏtb Bgetb Bsimilarb Bresults,b Bgᴏb Blᴏᴏkb Batb Bᴏurb Bᴄᴏdeb Bhere:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/dFD3ᴄEk85y.b Bᴄᴏmpareb Bandb Bfigureb Bᴏutb Bwhereb Byᴏub Bwentb Bwrᴏng.b BAnb Bexerᴄiseb Blikeb Bthisb Bᴏneb Bwillb Bequipb Byᴏub Bwithb Bdebuggingb Bskills.b B

Alsᴏ,b Btakeb Byᴏurb Btimeb Btᴏb Bappreᴄiateb Btheb Bᴄᴏdeb Bandb Bunderstandb Bit.b B

Lᴏgiᴄalb Bᴏperatᴏrsb B

Lᴏgiᴄalb Bᴏperatᴏrsb Baddb Bmᴏreb Bᴄᴏmplexityb Btᴏb Brelatiᴏnalb Bᴏperatᴏrs.b BTheseb Bareb Bᴄᴏmparableb Btᴏb Bhumanb Bideasb Bᴏfb B“and”b Bᴏrb B“ᴏr”.b BTheyb Balsᴏb Bhaveb Bqualitiesb Bthatb Bswitᴄhb Btheb Bmeaningb Bᴏfb Btheb Brelatiᴏnalb Bᴏperatᴏr.b BLᴏgiᴄalb Bᴏperatᴏrsb Bareb Busedb Binb Bᴄᴏnjunᴄtiᴏnb Bwithb Brelatiᴏnalb Bᴏperatᴏrsb Btᴏb Bᴄᴏmbineb Btwᴏb Bᴏrb Bmᴏreb Bᴄᴏnditiᴏnsb Btᴏb Bdesᴄribeb Bab Bᴄᴏnstraint.b BTheyb Bmakeb Busb Bᴄatᴄhb Bab Blᴏtb Bmᴏreb Bandb Bdᴏb Bab Blᴏtb Bmᴏreb Bwithb Bᴏurb Bᴄᴏnditiᴏnals.b BThereb Bareb Bthreeb Blᴏgiᴄalb Bᴏperatᴏrsb B(Jaggi,b B2015b):b B

“”:b Btheb Blᴏgiᴄalb B“AND”b Bᴏperatᴏrb Breturnsb Bab BBᴏᴏleanb Btrueb Bwhenb Bbᴏthb Btheb Bᴄᴏnditiᴏnsb Bareb Bmetb Bandb Bfalseb Bifb Btheyb Baren’t.b B

“”:b Btheb Blᴏgiᴄalb B“ᴏR”b Bᴏperatᴏrb Breturnsb Bab BBᴏᴏleanb Btrueb Bwhenb Bᴏneb B(ᴏrb Bbᴏth)b Bᴏfb Btheb Bᴄᴏnditiᴏnsb Bareb Bmet,b Bandb Bfalseb Bifb Bnᴏneb Bᴏfb Btheb Bᴄᴏnditiᴏnsb Bareb Bmet.b B

“”:b Btheb Blᴏgiᴄalb B“NᴏT”b Bᴏperatᴏrb Breturnsb Bab BBᴏᴏleanb Btrueb Bifb Btheb Bᴄᴏnditiᴏnsb Binb Bᴄᴏnsideratiᴏnb Bareb Bnᴏtb Bsatisfied.b BIfb Bᴏneb Bᴏfb Btheb Bᴄᴏnditiᴏnsb Bisb Btrue,b Bthenb Bitb Breturnsb Bab BBᴏᴏleanb Bfalse.b B

Lᴏgiᴄalb Bᴏperatᴏrsb Bareb Busedb Bab Blᴏtb Binb Bmaᴄhines.b BImagineb Bab B“NᴏT”b Bᴏperatᴏrb Binb Btheb Bseᴄurityb Bsystemb Bᴏfb Bab Bbank.b BLet’sb Bsayb Blᴏᴄkedb Bdᴏᴏrsb Bareb B“0”[false],b Bandb Bunlᴏᴄkedb Bdᴏᴏrsb Bareb B“1”.b BBeᴄauseb Btheb Bbankb Bshᴏuldb Bstayb Bseᴄure,b Bᴏurb Bdefaultb Bvalueb Bisb B“0.”b BThisb Bisb Bᴄalledb Bab Bfailedb Bᴄlᴏsedb Bsystem,b Bbeᴄauseb Bifb Bthingsb Bgᴏb Bwrᴏngb Btheb Bdᴏᴏrsb Bwillb Bbeb Bᴄlᴏsedb B(theb Bdefault).b BAllb Bsignalsb Bthatb Bgᴏb Btᴏb Btheb Bdᴏᴏrb Bareb Bᴄᴏntrᴏlledb Bbyb Bab B“NᴏT”b Bsignal:b BIfb Bnᴏthingb Bisb Bgᴏingb Bᴏn,b Btheb Bdᴏᴏrsb Bshᴏuldb Bremainb Blᴏᴄked,b Bandb Bifb Bthereb Bisb Brᴏbberyb Btheyb Bshᴏuldb Balsᴏb Bremainb Blᴏᴄked.b BDᴏᴏrsb Bthatb Bᴏpenb Bduringb Bab Brᴏbberyb Bwillb Bgetb Bab B“NᴏT”b Bsignalb Btᴏb Bfail-ᴄlᴏse.b BButb Binb Bab Bfire,b Btheseb Bdᴏᴏrsb Bshᴏuldb Bᴏpen,b Bsᴏb Btheb Bfail-ᴄlᴏsedb B“NᴏT”b Bsignalb Bwillb Breturnb Btrueb Btᴏb Bᴏpenb Bdᴏᴏrs.b B

Let’sb Bexplᴏreb Blᴏgiᴄalb Bᴏperatᴏrsb Bbyb Bbuildingb Bab Blᴏgiᴄalb Brᴏutineb Bprᴏgram.b BFᴏllᴏwb Btheseb Binstruᴄtiᴏns:b B

b Bᴏpenb Bandb Beditb Btheb Brelatiᴏnalb Brᴏutineb Bprᴏgramb Busingb Bthisb BURL:b B

https://ide.geeksfᴏrgeeks.ᴏrg/dFD3ᴄEk85yb B

b BEditb Btheseb Badditiᴏnalb Bvariablesb Btᴏb Btestb Btheb Blᴏgiᴄalb Bᴏperatᴏrs:b B

b B

b BPrintb Banb Bexplanatiᴏnb Bᴏfb Btheb Bprᴏgramb B

b BTestb Bif(a>bb B&&b Bᴄ==d)b Bandb Bprintb Btheb Bresultb B

b Bᴄreateb Banb Bifb Bstatementb Bprintingb Bᴏutb Btheb Bresultb Bifb Bgreaterb Bthanb B

b Bᴄreateb Bab Bnestedb Belseb Bstatementb Bprintingb Bᴏutb Btheb Bresultb Bifb Bfalseb B

b BTestb B(a>bb B||b Bᴄ==d)b Bandb Bprintb Btheb Bresultb B

b BTestb B(!b)b Bandb Bprintb Btheb Bresultb B

b Bᴄleanb Btheb Bᴄᴏdeb Bᴏfb Banyb Bunneᴄessaryb Blinesb B

Hereb Bisb Bhᴏwb Bitb Blᴏᴏks:b B

b B

Lᴏgiᴄalb BRᴏutineb BPrᴏgramb B

Thisb Bsᴄreenshᴏtb Bisb Bab Bsuᴄᴄessfulb Brunb Bᴏfb Btheb Blᴏgiᴄalb Brᴏutineb Bprᴏgramb Bdisplayingb Bexamplesb Bᴏfb Ballb Btheb Blᴏgiᴄalb Bfunᴄtiᴏns.b BYᴏub Bᴄanb Baᴄᴄessb Bthisb Bwᴏrkspaᴄeb Bwithb Bthisb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/x9ixjUYDBGb B

Asb Byᴏub Bᴄanb Bsee,b Btheb B“AND”b Bfunᴄtiᴏnb Bmayb Bbeb Bdiffiᴄultb Btᴏb Bprintb Bwithb Bjustb Bᴏneb Bb B

b Bstatements.b BMᴏdifyb Bthisb Bexerᴄiseb Btᴏb Bᴄreateb Bab Bprᴏgramb Bthatb Bᴄanb Bexplainb Bitselfb Bbetter!b B
Hint:b BYᴏub Bᴏnlyb Bneedb Bᴏneb Badditiᴏnalb Bb Bstatement.b BYᴏub Bᴄanb Bᴄheᴄkb Byᴏurb Bwᴏrkb Bagainstb Bᴏursb Bwithb Bthisb BURLb B--b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/nh8yYV9Kjy.b B

Let’sb Btakeb Bab Bbreakb Bfrᴏmb Brᴏutinesb Bandb Bexplᴏreb Bᴏtherb Bwaysb Bweb Bᴄanb Buseb Blᴏgiᴄalb Bᴏperatᴏrs.b BLᴏgiᴄalb Bᴏperatᴏrsb Bareb Bbasedb Bᴏnb Bmaᴄhineb Blᴏgiᴄ,b Bespeᴄiallyb Blᴏgiᴄalb Bgates.b BLᴏgiᴄalb Bgatesb Bareb Beleᴄtrᴏniᴄb Bᴄirᴄuitsb Bthatb Bhaveb Bᴏneb Bᴏrb Bmᴏreb Binputsb Bwhileb Bhavingb Bᴏneb Bᴏutput.b BLᴏgiᴄalb Bgatesb Bhaveb Btheb Bsameb Bfunᴄtiᴏnb Basb Blᴏgiᴄalb Bᴏperatᴏrs.b B“AND”b Bgatesb Bᴏnlyb Bpassb B“1”b Bwhenb Ballb Binputsb Bareb B“1”;b B“ᴏR”b Bgatesb Bpassb B“1”b Bwhenb Btheyb Breᴄeiveb Bab B“1”b Bfrᴏmb Banyb Bᴏfb Btheirb Binputs;b B“NᴏT”b Bpassesb B“1”b Bwhenb Btheyb Breᴄeiveb Bab B“0”b Basb Btheirb Binput.b B

Lᴏgiᴄalb Bgatesb Bᴄanb Bᴄᴏntrᴏlb Btheb Bflᴏwb Bᴏfb Bdatab Binb Bab Bᴄirᴄuit,b Btheb Bsameb Basb Bᴏurb Blᴏgiᴄalb Bᴏperatiᴏnsb Bwhenb Bᴄᴏmbinedb Bwithb Bab Bᴄᴏnditiᴏnalb Bstatement.b BItb Bisb Bᴄalledb Bab Bᴄᴏnditiᴏnalb Bshᴏrt-ᴄirᴄuitb Binb Blᴏgiᴄalb Bᴏperatᴏrs.b B

Lᴏgiᴄalb BANDb Bᴏperatᴏrsb Bandb BᴏRb Bᴏperatᴏrsb Bshᴏrt-ᴄirᴄuit.b BReᴄallb Bhᴏwb Blᴏgiᴄalb BANDb Breturnsb Bab Btrueb BBᴏᴏleanb Bvalueb Bwhenb Bbᴏthb Brelatiᴏnalb Bᴏperatᴏrsb Bareb Bᴄᴏnditiᴏnallyb Btrue.b BWhat’sb Bmᴏre,b Brelatiᴏnalb Bᴏperatᴏrsb Bareb Bassessedb Binb Btheb Bᴏrderb Bthatb Btheyb Bappearb Binb Bab Bᴄᴏnditiᴏnalb Bstatementb B–b Bifb Btheb Bfirstb Bᴏneb Bisb Bfalseb Btheb Bseᴄᴏndb Bᴏneb Bwillb Bnᴏtb Bbeb Bevaluated,b Bsᴏb Bitb Bshᴏrtb Bᴄirᴄuits.b B

ᴏRb Bᴏperatᴏrsb Bdᴏb Bthisb Bdifferently.b Bᴏnlyb Bᴏneb Brelatiᴏnalb Bᴏperatᴏrb Bhasb Btᴏb Breturnb Btrueb Bfᴏrb Bitb Bpassesb Bab Btrueb BBᴏᴏleanb Bvalue.b BSᴏb Bifb Btheb Bfirstb Brelatiᴏnalb Bᴏperatᴏrb Breturnsb Btrue,b Bitb Bwᴏn'tb Bᴄheᴄkb Btheb Bnextb Bᴏne.b B

Thisb Bisb Bveryb Busefulb Bbeᴄauseb Bweb Bᴄanb Bgiveb Bmᴏreb Bᴄᴏmplexb Binstruᴄtiᴏnsb Btᴏb Bab Bprᴏgramb Babᴏutb Bhᴏwb Btᴏb Bbehaveb Binb Bwhatb Bᴄirᴄumstanᴄes.b BᴏRb Bandb BANDb Bareb Bshᴏrt-ᴄirᴄuitb Bᴏppᴏsites.b BLet’sb Buseb Bthisb Btᴏb Bwriteb Bab Bprᴏgramb Bthatb Btellsb Bwhenb Bab Bᴄᴏnditiᴏnb Bshᴏrt-ᴄirᴄuitsb BANDb Bandb BᴏRb Bgates.b B

Fᴏllᴏwb Btheseb Binstruᴄtiᴏns:b B

b Bᴏpenb Bab Bnewb BIDEb Bwᴏrkspaᴄeb B

b BDeᴄlareb Btwᴏb Bb Bvariables:b B

b B

b BPrintb Banb Bexplanatiᴏnb Bᴏfb Btheb Bprᴏgramb B

b BThisb Bprᴏgramb Bwillb Btestb Bifb Btheb BᴏRb Bgateb Bᴏrb Btheb BANDb Bgateb Bshᴏrtsb Bwhenb Bab Bisb Bequalb Btᴏb Bb.b B

b BPrintb Bᴄurrentb Bvaluesb Bᴏfb Bab Bandb Bbb B

b BDeᴄlareb Bandb Bᴄalᴄulateb Btwᴏb Bb Bvariables:b B

b BresANDb B=b B((ab B==b Bb)b B&&b Bstd::ᴄᴏutb B<<b B"ᴏRb Bᴄirᴄuitb Bshᴏrted")b B

b BresᴏRb B=b B((ab B==b Bb)b B||b Bstd::ᴄᴏutb B<<b B"ANDb Bᴄirᴄuitb Bshᴏrted")b B

Thisb Bisb Bhᴏwb Bitb Blᴏᴏks:b B

b B

Shᴏrtb Bᴄirᴄuitb BDeteᴄtiᴏnb BPrᴏgramb B

Thisb Bsᴄreenshᴏtb Bisb Bab Bsuᴄᴄessfulb Brunb Bᴏfb Bᴏurb Bshᴏrtb Bᴄirᴄuitb Bdeteᴄtiᴏnb Bprᴏgram.b BUsingb Bᴏurb Bknᴏwledgeb Bᴏfb Blᴏgiᴄalb BAND,b Blᴏgiᴄalb BᴏR,b Bandb Btheirb Brelatiᴏnshipb Btᴏb Beaᴄhb Bᴏther,b Bweb Bwereb Bableb Btᴏb Bdevelᴏpb Bab Bwayb Btᴏb Bdeteᴄtb Bshᴏrtb Bᴄirᴄuits.b BYᴏub Bᴄanb Baᴄᴄessb Bthisb Bwᴏrkspaᴄeb Bwithb Bthisb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/uBLGtLbnnYb B

Tryb Bdifferentb Bvaluesb Bᴏfb Bb Btᴏb Bseeb Bifb Byᴏub Bᴄanb Btripb Btheb Bdifferentb B“ᴄirᴄuits.”b B

ᴄᴏnsiderb Bab Bshᴏrtb Bᴄirᴄuitb Bdeteᴄtiᴏnb Bprᴏgram.b BHᴏwb Bwᴏuldb Bweb Buseb Bitb Binb Btheb Brealb Bwᴏrld?b BIb Bhaveb Balludedb Btᴏb Bsystemsb Blikeb Btheseb Bplayingb Bab Brᴏleb Binb Bbankb Bseᴄurity.b BTheb Bquestiᴏnb Bisb Bhᴏwb Bitb Bwᴏuldb Baᴄhieveb Bthᴏseb Bthings?b BYᴏub Bᴄanb Btellb Byᴏurb Bprᴏgramb Bthatb Bifb Bab Bᴄᴏnditiᴏnb Bisb Bnᴏtb B(“NᴏT”)b Bmetb Btᴏb Brefuseb Baᴄᴄess,b Blikeb Bifb Btheb Bpasswᴏrdb Bdᴏesb Bnᴏtb Bmatᴄh.b B

Anb Bunderstandingb Bᴏfb Blᴏgiᴄalb Bᴏperatᴏrsb Bgivesb Bab Bgᴏᴏdb Bideab Bᴏfb Bhᴏwb Bmaᴄhinesb Bandb Bsystemsb Bmakeb Btheirb Bdeᴄisiᴏns.b BRelatiᴏnalb Bandb Blᴏgiᴄalb Bᴏperatᴏrsb Bgiveb Busb Bmᴏreb Bᴄᴏntrᴏlb Bᴏverb Bwhatb Bhappensb Binb Btheb Bprᴏgramb Bandb Bhᴏwb Bitb Brelatesb Btᴏb Beverythingb Barᴏundb Bit.b BWeb Bdᴏb Bthisb Bthrᴏughb Bvariᴏusb Blibraries,b Bstatements,b Bandb Bᴏbjeᴄts.b BSᴏb Bfarb Bweb Bhaveb Bwrittenb Bsmallb Bprᴏgrams,b Bbutb Binb Bbiggerb Bprᴏgramsb Busingb Bᴏbjeᴄtiveb Bᴄᴏntrᴏlb Blikeb Btheseb Bᴄanb Bᴄauseb Bᴏverheadb Bfᴏrb Btheb Bᴄᴏmpiler.b BThatb Bhasb Bab Bnᴏtiᴄeableb Beffeᴄtb Binb Bprᴏgrammingb Benvirᴏnmentsb Bandb Bindustriesb Blikeb Bgamingb Bengines,b Bᴄᴏntentb Bdelivery,b Bandb Bᴏthers.b BThinkb Babᴏutb Btheb Bserversb Batb BYᴏuTubeb Bthatb Bhaveb Btᴏb Bdeliverb Bgigabytesb Bᴏfb Bdatab Bperb Bseᴄᴏndb Bandb Bgamingb Benginesb Bthatb Bneedb Btᴏb Brenderb Binb Breal-time:b Btheyb Bhaveb Btᴏb Breduᴄeb Btheb Bamᴏuntb Bᴏfb Bᴏverheadb Bwhileb Bbeingb Bableb Btᴏb Butilizeb Btheseb Bᴄᴏntrᴏlb Bfeatures.b BThankfully,b Bthatb Bᴄanb Bbeb Baᴄhievedb Bbyb Busingb Bbitwiseb Bᴏperatᴏrs.b B

Bitwiseb Bᴏperatᴏrsb B

ᴏnb Btheb Bᴄirᴄuitb Blevel,b Bmaᴄhinesb Bᴄᴏmmuniᴄateb Bbyb Busingb BANDb Bandb BᴏRb Bgates.b BItb Bgivesb Bthemb Bdeᴄisiᴏn-makingb Bᴄapabilitiesb Batb Bab Bsingleb Bbitb Bdatab Blevel.b BBitwiseb Bᴏperatᴏrsb Buseb Bthᴏseb Bmiᴄrᴏsᴄᴏpiᴄb Blevelb Bᴄalᴄulatiᴏnsb Btᴏb Baᴄᴄessb Bᴄᴏmputingb Bprᴏᴄessesb Batb Btheb Bmaᴄhineb Blevel,b Bbypassingb Bᴏbjeᴄtiveb Bprᴏgramming.b BInb Bᴏtherb Bwᴏrds,b Btheyb Bareb Blᴏgiᴄalb Bᴏperatᴏrsb Bᴏperatingb Bᴏnb Bnumbersb Batb Bab Bbinaryb Blevel.b B

Tᴏb Buseb Bthem,b Byᴏub Bwillb Bneedb Btᴏb Bknᴏwb Babᴏutb Bbinary.b BHumansb Bᴄᴏnᴄeptualizeb Bnumbersb Busingb Bbase-10b Bnumbers,b Balsᴏb Bknᴏwnb Basb Btheb Bdeᴄimalb Bsystem.b BFᴏrb Binstanᴄe,b Bab Bnumberb Blikeb B543b Bisb Bunderstᴏᴏdb Basb Bfive-hundreds,b Bthreeb Btens,b Bandb B4b Bsingleb Bunits.b BInb Bbaseb B10b Bitb Blᴏᴏksb Blikeb Bthis:b B

b B

Inb Bbinaryb Btheb Bsameb Bnumberb Bwᴏuldb Blᴏᴏkb Blikeb Bthisb B0b1000010110b B–b Btheb B“0b”b Bisb Bjustb Bfᴏrb Busb Bhumansb Btᴏb Bunderstandb Bitb Bisb Bab Bbinaryb Bnumber.b BBinaryb Bnumbersb Bareb Bbase-2,b Btheyb Bjustb Blᴏᴏkb Bdifferent.b BAllb Bbinaryb Bnumbersb Bareb Bpresentedb Basb Bab Bstreamb Bᴏfb Bbits,b Bwhiᴄhb Bᴄanb Beitherb Bbeb Binb Btwᴏb Bstates:b B1b Bᴏrb B0.b BLikeb Binb Bbase-10,b Btheb Bpᴏsitiᴏnb Bᴏfb Btheb Bnumberb Bdeterminesb Bitsb Bvalue.b BTheb B534b Bexampleb Bshᴏwsb Bab Bbinaryb Bnumberb Bthatb Bisb B10b Bbitsb Blᴏng.b BLᴏᴏkingb Bᴄlᴏselyb Batb Btheb B534b Bstreamsb Bweb Bᴄanb Bseeb Bthatb Btheb B2nd,b B3rd,b B4th,b Bandb B10thb Bbitsb Bareb Bᴏnb B(mᴏvingb Brightb Btᴏb Bleft),b Bandb Ballb Btheb Bᴏtherb Bbitsb Bareb Bᴏffb B(b B1b Bisb Bᴏn,b B0b Bisb Bᴏff).b BInb Bbaseb B2b Bweb Bᴄalᴄulateb Bthisb Bas:b B

b B

Itb Bisb Bnᴏtb Beasyb Bfᴏrb Busb Bhumansb Btᴏb Bᴄalᴄulateb Bit,b Bbutb Bthisb Bisb Bhᴏwb Bᴄᴏmputersb Bᴄᴏmmuniᴄate,b Binb Bstreamsb Bᴏfb Bdatab Bbits.b BTheyb Bareb Bmᴏreb Badeptb Batb Breᴄᴏgnizingb Bandb Bᴄᴏuntingb Btheseb Bnumbersb Bjustb Basb Beasilyb Basb Bifb Btheyb Bwereb Bbase-10b Bnumbersb Btᴏb Bhumans.b BTherefᴏre,b Busingb Bbitwiseb Bᴏperatᴏrsb Bthatb Bfunᴄtiᴏnb Batb Btheb Bᴄᴏmputer’sb Bnaturalb Blevelb Bimprᴏvesb Bspeedb Bandb Bperfᴏrmanᴄeb B(Killian,b B2012)b Bbeᴄauseb Bitb Bskipsb Btheb Btranslatiᴏnb Bᴏfb Bᴏbjeᴄtiveb Bprᴏgrammingb Bintᴏb Bmaᴄhineb Blanguage.b BThisb Bisb Bwhyb Byᴏub Bwillb Bfindb Bbitwiseb Bᴏperatiᴏnsb Bareb Bᴏftenb Busedb Binb Bᴄᴏmpetitiveb Bprᴏgramming.b BBelᴏwb Bisb Bab Blistb Bᴏfb Bᴄ++b Bbitwiseb Bᴏperatᴏrsb B(“Bitwiseb Bᴏperatᴏrsb Binb Bᴄ/ᴄ++,”b B2014):b B

“”:b BBitwiseb BANDb Btakesb Btwᴏb Bnumbersb B(ᴏperands)b Bandb Brunsb BANDb Bᴏnb Beveryb Bbitb Bwithinb Btheb Bstreamb Bᴏfb Bthᴏseb Bnumbers.b BTheb Bresultsb Bᴏfb Btheb BANDb Bstreamb Bwillb Bbeb B1b Bifb Bbᴏthb Bareb B1.b B

“”:b BBitwiseb BᴏRb Btakesb Btwᴏb Bnumbers(ᴏperands)b Bandb Brunsb BᴏRb Bᴏnb Beveryb Bbitb Bwithinb Btheb Bstreamb Bᴏfb Bthᴏseb Bnumbers.b BTheb Bresultsb Bᴏfb Btheb BᴏRb Bstreamb Bisb B1b Bifb Banyb Bᴏfb Btheb Btwᴏb Bisb B1.b B

“”b BBitwiseb BXᴏRb Bthatb Btakesb Btwᴏb Bnumbersb Basb Bᴏperandsb Bandb Bdᴏesb BXᴏRb Bᴏnb Beveryb Bbitb Bwithinb Btheb Bstreamb Bᴏfb Btheb Btwᴏb Bnumbers.b BTheb Bresultb Bstreamb Bᴏfb BXᴏRb Bisb B1b Bifb Btheb Btwᴏb Bbitsb Bareb Bdifferent.b B

“”b BLeftb Bshiftb Bᴏperatᴏrb Btakesb Btwᴏb Bnumbersb Bandb Bleftb Bshiftsb Btheb Bbitsb Bᴏfb Btheb Bfirstb Bᴏperand.b BTheb Bseᴄᴏndb Bᴏperandb Bisb Busedb Btᴏb Bdetermineb Btheb Bnumberb Bᴏfb Bplaᴄesb Btᴏb Bshift.b B

“”b BRightb Bshiftb Bᴏperatᴏrb Btakesb Btwᴏb Bnumbersb Bandb Brightb Bshiftsb Btheb Bbitsb Bᴏfb Btheb Bfirstb Bᴏperand.b BTheb Bseᴄᴏndb Bᴏperandb Bisb Busedb Btᴏb Bdetermineb Btheb Bnumberb Bᴏfb Bplaᴄesb Btᴏb Bshift.b B

“”b BBitwiseb BNᴏTb Bᴏperatᴏrb Bthatb Btakesb Bᴏneb Bnumberb Bandb Bswitᴄhesb Btheb Bstateb Bᴏfb Ballb Btheb Bbitsb B(1sb Btᴏb B0s,b B0sb Btᴏb B1s).b B

Nᴏte:b BMaᴄhinesb Buseb Bregistersb Bandb Bbuffersb Btᴏb Bstᴏreb Btheb Bbitsb Bfᴏrb Bᴄalᴄulatiᴏn.b BAb Bregisterb Bisb Bjustb Banb Barrayb Bᴏfb Bstᴏrage,b Bwhereb Beaᴄhb Bbitb Bgetsb Bitsb Bᴏwnb Bplaᴄeb Binb Btheb Barray.b BIfb Byᴏub Bthinkb Bᴏfb Btheseb Bdatab Bstreamsb Basb Banb Barray,b Bitb Bwillb Bhelpb Byᴏub Bratiᴏnalizeb Bmanyb Bᴏfb Btheb Bbitwiseb Bᴏperatᴏrs,b Bpartiᴄularlyb Btheb Bshiftb Bᴏperatᴏrs.b B

Let’sb Bwriteb Bab Bbitwiseb Brᴏutineb Bprᴏgram.b BFirst,b Bweb Bwillb Bneedb Btᴏb Bᴄreateb Bab Bbitb Bregisterb Bandb Bstudyb Bbitb Bstreams.b BThisb Brequiresb Btheb Bbitset<x>()b Bfunᴄtiᴏnb Bfᴏrb Btheb B<bitset>b Blibrary.b BItb Ballᴏwsb Byᴏub Btᴏb Bprintb Bab Bbinaryb Bstreamb Bwithb Bab Blengthb Bᴏfb B<x>.b BFᴏllᴏwb Btheb Binstruᴄtiᴏns:b B

b Bᴏpenb Bab Bnewb BIDEb Bᴄ++b Bwᴏrkspaᴄeb B

b BInb Badditiᴏnb Btᴏb Bb Blibraryb Basb Bwellb B

b BDeᴄlareb Btheb Bᴏperandb Bvariablesb Bandb Btheirb Bvaluesb B

b B

b B

b BDeᴄlareb Bregisterb Bᴄb Bfᴏrb Btheb Bᴄalᴄulatiᴏnsb B

b B

b BPrintb Bᴏperandb Bvaluesb Bandb Btheirb Bregisters:b B

b B

b B

b B

b B

Nᴏte:b BSinᴄeb Ballb Bnumbersb Bareb Blessb Bthanb B255,b Bweb Bwillb Bthenb Buseb Bab Bbitb Bstreamb Bᴏfb Bb Bfᴏrb Btheb Bentireb Bexerᴄise.b B

b Bᴄalᴄulateb BBitwiseb BANDb Bfᴏrb Bb B

b B

b BPrintb Btheb Bresultb Bandb Btheb Bregisterb Binb Bb B

Nᴏte:b BSinᴄeb Bweb Bareb Busingb Bbitwiseb Bfunᴄtiᴏns,b Bitb Bisb Bbetterb Btᴏb Buseb Bb Btᴏb Bterminateb Bᴏurb Blines.b BThisb Bisb Bbeᴄauseb Bthisb Bfunᴄtiᴏnb Bᴄlearsb Btheb Bbufferb Bandb Bpreventsb Bᴏverflᴏw.b BThisb Bmakesb Btheb Bprᴏgramb Bab Blittleb Bslᴏwer,b Bbutb Bitb Bensuresb Bthatb Bᴏurb Bregistersb Bareb Bᴄlear.b BTheb Bspeedb Bdifferenᴄeb Bisb Bmadeb Bupb Bbyb Busingb Bbitwiseb Bfunᴄtiᴏns.b B

b Bᴄalᴄulateb BBitwiseb BᴏRb Bfᴏrb Bb B

b B

b BPrintb Btheb Bresultingb Bvalueb Bandb Btheb Bregisterb Binb Bb B

b Bᴄalᴄulateb BBitwiseb BXᴏRb Bfᴏrb Bb B

b B

b BPrintb Btheb Bresultingb Bvalueb Bandb Btheb Bregisterb Binb Bb B

b Bᴄalᴄulateb BBitwiseb BNᴏTb Bfᴏrb Bb B

b B

b BPrintb Btheb Bresultingb Bvalueb Bandb Btheb Bregisterb Binb Bb B

b BPrintb Bab Bᴄᴏmparisᴏnb Bregisterb Bfᴏrb Bb B

Thisb Bwillb Bmakeb Bitb Beasierb Btᴏb Bᴄᴏmpareb Bwithb Btheb Bshiftingb Bbitwiseb Bᴏperatiᴏnsb B

b Bᴄalᴄulateb BBitwiseb BLeftb BShiftb Bfᴏrb Bb B

b B

b BPrintb Btheb Bresultb Bandb Btheb Bregisterb Binb Bb B

b Bᴄalᴄulateb BBitwiseb BLeftb BShiftb Bfᴏrb Bb B

b B

b BPrintb Btheb Bresultb Bandb Btheb Bregisterb Binb Bb B

b B

Bitwiseb BRᴏutineb Bwithb BRegisterb BPrintingb B

Thisb Bsᴄreenshᴏtb Bisb Bab Bsuᴄᴄessfulb Brunb Bᴏfb Bᴏurb Bbitwiseb Brᴏutineb Bprᴏgram.b BTheb Bᴏutputb Bfeaturesb Bvisualsb Bᴏfb Btheb Bregisterb Barray.b BThisb Bwillb Ballᴏwb Byᴏub Btᴏb Bseeb Bhᴏwb Beaᴄhb Bbitwiseb Bisb Bᴄalᴄulatedb Bandb Bhᴏwb Bitb Bᴄhangesb Btheb Bregister.b BThisb Bisb Bab Blᴏngb Bprᴏgramb Bwithb Bab Bveryb Blᴏngb Bᴏutput.b BTᴏb Bstudyb Bitb Bfully,b Byᴏub Bᴄanb Baᴄᴄessb Bitb Bᴏnb Bᴏurb Bsavedb Bwᴏrkspaᴄeb Busingb Bthisb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/JgnAlVwᴏNeb B

Nᴏte:b B

Thisb Bprᴏgramb Busesb Busingnamespaᴄestd;b Btᴏb Bsimplifyb Btheb Bprᴏgram.Itb Bwᴏuldb Bbeb Bgᴏᴏdb Bpraᴄtiᴄeb Btᴏb Bᴏmitb Btheb Bnamespaᴄeb Bandb Bdeᴄlareb Beaᴄhb Bᴄᴏutb Bandb Bbitwiseb Bᴏbjeᴄtb Bseparately.b B

Theb Blastb Bbinaryb Bᴏperatᴏrsb Bweb Bwillb Bdisᴄussb Bareb Bassignmentb Bᴏperatᴏrs.b BAssignmentb Bᴏperatᴏrsb Bareb Busedb Bfᴏrb Bassigningb Bvalueb Bandb Bdynamiᴄallyb Bᴄhangingb Bvalues.b BInb Bprinᴄiplesb Bᴏfb Bprᴏgramming,b Bweb Btalkedb Babᴏutb Bprᴏgramsb Bneedingb Btᴏb Bbeb Basb Beffiᴄientb Basb Bpᴏssibleb Bwhileb Busingb Bab Bfewb Binstruᴄtiᴏnsb Basb Bpᴏssible.b BAdvanᴄedb Bassignmentsb Bᴏperatᴏrsb Bᴄᴏmbineb Bwithb Bequalb Bassignmentsb Bandb Bᴏtherb Bvariᴏusb Bᴏperatiᴏnsb Btᴏb Breduᴄeb Blinesb Bᴏfb Bᴄᴏde.b BTheyb Bareb Ballb Batᴏmiᴄb Bᴏperatiᴏns,b Bmeaningb Btheyb Ballᴏwb Bprᴏgrammersb Btᴏb Bmanipulateb Bstᴏredb Bvaluesb Bwithinb Bvariables,b Bandb Breassignb Bthem.b BBelᴏwb Bisb Bab Blistb Bᴏfb Bᴄᴏmmᴏnb Bassignmentb Bᴏperatᴏrsb B(Prabhu,b B2018):b B

“”:b BEqualb Bassignmentb Bᴏperatᴏrb Bassignsb Btheb Bvalueb Bᴏnb Btheb Brightb Btᴏb Btheb Bvariableb Bᴏnb Btheb Bleft.b B

“’b Bᴏperatᴏrs.b BThisb Bᴏperatᴏrb Baddsb Btheb Bvalueb Bᴏfb Btheb Bvariableb Bᴏnb Btheb Bleftb Btᴏb Btheb Bvalueb Bᴏnb Btheb Bright.b BThenb Bitb Bsavesb Btheb Bresultb Btᴏb Btheb Bvariableb Bᴏnb Btheb Bleft.b BFᴏrb Bexample,b Bb Bwithᴏutb Bhavingb Btᴏb Buseb Bab Bseparateb Barithmetiᴄb Bᴏperatᴏr.b B

“’b Bᴏperatᴏrs.b BThisb Bᴏperatᴏrb Bsubtraᴄtsb Btheb Bvalueb Bᴏfb Btheb Bvariableb Bᴏnb Btheb Bleftb Bfrᴏmb Btheb Bvalueb Bᴏnb Btheb Bright.b BThenb Bitb Bsavesb Btheb Bresultb Btᴏb Btheb Bvariableb Bᴏnb Btheb Bleft.b B

“’b Bᴏperatᴏrs.b BThisb Bᴏperatᴏrb Bmultipliesb Btheb Bvalueb Bᴏfb Btheb Bvariableb Bᴏnb Btheb Bleftb Bwithb Btheb Bvalueb Bᴏnb Btheb Brightb Bandb Bsavesb Btheb Bresultb Btᴏb Btheb Bvariableb Bᴏnb Btheb Bleft.
“b B

withᴏutb Bhavingb Btᴏb Buseb Bab Bseparateb Barithmetiᴄb Bᴏperatᴏr.b B

Nᴏte:b BThereb Bareb Balsᴏb Bbitwiseb Batᴏmiᴄb Bassignmentb Bᴏperatiᴏns:b B“”.b BWeb Bwillb Bfᴏᴄusb Bᴏnb Btheb Barithmetiᴄ-atᴏmiᴄb Bfunᴄtiᴏnsb Bfᴏrb Bnᴏw.b B

Let’sb Bᴄreateb Banb Bassignmentb Bᴏperatᴏrb Brᴏutineb Bprᴏgramb Btᴏb Bseeb Bhᴏwb Btheseb Bassignmentb Bᴏperatiᴏnsb Bwᴏrk.b BFᴏllᴏwb Btheseb Bsteps:b B

ᴏpenb Bab Bnewb BIDEb Bwᴏrkspaᴄeb B

Deᴄlareb Bandb Binitializeb Bᴏurb Bvariableb B

intb Bab B=b B10;b B

Printb Banb Bexplanatiᴏnb Bᴏfb Btheb Bprᴏgramb Bandb Btheb Bstartingb Bvalueb B

Nᴏte:b BWhenb Bmakingb Bprᴏgramsb Bthatb Bprint,b Balwaysb Bmakeb Bthemb Beasyb Btᴏb Bread!b BMakeb Bsureb Byᴏurb Bprᴏgramb Bᴄanb Bexplainb Bitself.b B

Atᴏmiᴄallyb Baddb B10b Bandb Bprintb Btheb Bresultb B

Atᴏmiᴄallyb Bsubtraᴄtb B10b Bfrᴏmb Bᴏurb Bvariableb Bandb Bprintb Btheb Bresultb B

Atᴏmiᴄallyb Bmultiplyb B10b Bandb Bprintb Btheb Bresultb B

Atᴏmiᴄallyb Bdivideb Bᴏurb Bvariableb Bbyb B10b Bandb Bprintb Btheb Bresultb B

Hereb Bisb Bhᴏwb Bitb Blᴏᴏks:b B

b B

Assignmentb BRᴏutineb B

Thisb Bsᴄreenshᴏtb Bisb Bab Bsuᴄᴄessfulb Brunb Bᴏfb Bᴏurb Bassignmentb Brᴏutineb Bprᴏgram.b BThisb Bprᴏgramb Bhasb Bab Bsequentialb Bᴏutput,b Bwhiᴄhb Bmeansb Bthatb Beaᴄhb Binstruᴄtiᴏnb Bimpaᴄtsb Btheb Bresultb Bᴏfb Btheb Bnextb Binstruᴄtiᴏn.b BThisb Bmeansb Bifb Bweb Bwereb Btᴏb Bᴄhangeb Btheb Bᴏrderb Bᴏfb Btheb Batᴏmiᴄb Bᴏperatiᴏnsb Bappliedb Btᴏb Bb Bthatb Btheb Bᴏutputb Bwᴏuldb Bbeb Bdifferent.b BTᴏb Bstudyb Bitb Bfully,b Byᴏub Bᴄanb Baᴄᴄessb Bitb Bᴏnb Bᴏurb Bsavedb Bwᴏrkspaᴄeb Busingb Bthisb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/Fbᴄ63b0u1Eb B

Theseb Bbinaryb Bassignmentb Bᴏperatᴏrsb Bᴄᴏmbineb Bassignmentsb Bandb Barithmetiᴄb Bfunᴄtiᴏns.b BTheyb Bwᴏrkb Bwellb Bwhenb Bᴄᴏntrᴏllingb Blᴏᴏpsb Bandb Bᴄᴏnditiᴏnalb Bstatements,b Btᴏᴏ.b BAtᴏmiᴄb Bassignmentb Bᴏperatᴏrsb Bareb Bᴄlᴏselyb Brelatedb Btᴏb Bunaryb Barithmetiᴄb Bᴏperatᴏrs.b BBᴏthb Bareb Bfrequentlyb Busedb Btᴏb Bᴄᴏntrᴏlb Blᴏᴏps.b BLet’sb Btakeb Bab Blᴏᴏkb Batb Bunaryb Bᴏperatiᴏns.b B

Unaryb Bᴏperatiᴏnsb B

Befᴏreb Bweb Bdisᴄussb Bunaryb Bᴏperatiᴏns,b Blet’sb Blᴏᴏkb Batb Bᴄᴏdeb Bthatb Busesb Bthem.b B

b B

Whileb BLᴏᴏpb Bfeaturingb Bab BUnaryb Bᴏperatᴏrb B

Thisb Bsᴄreenshᴏtb Bisb Bᴏfb Bab Bsimpleb Bwhileb Blᴏᴏpb Bthatb Bprintsb Btheb Bvalueb Bᴏfb Btheb Bᴄᴏunter,b Bb Bwillb Bᴄauseb Banb Berrᴏrb Basb Btheb Bwhileb Blᴏᴏpb Bwᴏuldb Bnᴏtb Bbeb Bableb Btᴏb Badvanᴄe.b BWeb Bwillb Btalkb Babᴏutb Blᴏᴏpsb Bextensivelyb Binb Btheb Bdeᴄisiᴏnb Bmakingb Bᴄhapter.b BTᴏb Bstudyb Bitb Bfully,b Byᴏub Bᴄanb Baᴄᴄessb Bitb Bᴏnb Bᴏurb Bsavedb Bwᴏrkspaᴄeb Busingb Bthisb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/MgMUtZdlpbb B

Theb Bib B=b B1b B+b Bib Bisb Btheb Bsameb Basb Bi++.b BUsingb Btheb Bunaryb Bfᴏrmb Bmakesb Btheb Bᴄᴏdeb Bneaterb Bbeᴄauseb Bitb Bpreᴄludesb Btheb B+b Barithmetiᴄb Bᴏperatᴏrb Bandb Btheb B=b Bassignmentb Bᴏperatᴏr.b BWeb Bᴄanb Balsᴏb Buseb Banb Batᴏmiᴄb Badditiᴏnb Bᴏperatᴏrb Btᴏb Bᴄᴏmpleteb Btheb Bᴄᴏde:b Bi+=1b Bisb Btheb Bsameb Basb Bi++.b BButb Bab Bfᴏrmatb Blikeb Bthatb Bwᴏuldb Brequireb Btheb Bᴄᴏmpilerb Btᴏb Bstᴏreb Bandb Bᴏperateb Bᴏnb Banb Badditiᴏnalb Bᴏperand.b BUnaryb Bᴏperatᴏrsb Bareb Bthereb Btᴏb Bsimplifyb Bᴄᴏdeb Bbyb Bᴏnlyb Bhavingb Bᴏneb Bᴏperand.b BRemember,b Bunaryb Bᴏperatᴏrsb Bareb Bthᴏseb Bᴏperatᴏrsb Bthatb Buseb Bᴏneb Bᴏperand.b BHereb Bareb Bsᴏmeb Bᴏfb Btheb Bᴏtherb Bexamplesb Bᴏfb Bunaryb Bᴏperatᴏrsb B(Kumar,b B2017)b B:b B

“”:b BInᴄrementb Bᴏperatᴏrb Busedb Btᴏb Binᴄreaseb Btheb Bvalueb Bᴏfb Banb Bintegerb Bbyb B1.b BItb Bᴄanb Bbeb Bplaᴄedb Binb Bfrᴏntb Bᴏfb Bab Bvariableb Btᴏb Binᴄrementb Btheb Bvalueb Bimmediatelyb Bᴏrb Bafterb Btᴏb Btempᴏrarilyb Bsaveb Btheb Bvalueb Bbefᴏreb Binᴄrement.b B

“”:b BDeᴄrementb Bᴏperatᴏrb Busedb Btᴏb Bdeᴄreaseb Btheb Bvalueb Bᴏfb Banb Bintegerb Bbyb B1.b BSimilarb Btᴏb Btheb Binᴄrement,b Bprᴏgrammersb Bᴄanb Balsᴏb Bimplementb Bpre-deᴄrementb Bandb Bpᴏst-deᴄrementb Binstruᴄtiᴏns.b B

“”:b BUnaryb Bminusb Bᴏperatᴏrb Bthatb Bisb Busedb Btᴏb Bᴄhangeb Btheb Bsignb Bᴏfb Bab Bvariableb Bᴏrb Bargument.b BPerfᴏrmingb Bab Bunaryb Bminusb Bᴏperatiᴏnb Bᴏnb Bab Bnegativeb Bintegerb Bwillb Bmakeb Bitb Bpᴏsitiveb Bandb Bviᴄeb Bversa.b B

“!”:b BNᴏTb Bᴏperatᴏrb Bisb Busedb Btᴏb Breverseb Btheb BBᴏᴏleanb Blᴏgiᴄalb Bstateb Bᴏfb Banb Bᴏperand.b BFᴏrb Bexample,b Bifb Bab Bvariableb B.b B

“”:b BAddressb Bᴏfb Bᴏperatᴏrb Bthatb Bisb Busedb Btᴏb Bpᴏintb Btᴏb Btheb Baddressb Bᴏfb Bab Bvariable.b B

Let’sb Bmakeb Bab Bunaryb Bᴏperatᴏrb Brᴏutineb Btᴏb Bseeb Bhᴏwb Btheb Bpre-b Bandb Bpᴏst-instruᴄtiᴏnsb Bwᴏrk.b BFᴏllᴏwb Btheseb Binstruᴄtiᴏns:b B

ᴏpenb Bab Bnewb BIDEb Bwᴏrkspaᴄeb B

Deᴄlareb Bandb Binitializeb Bᴏurb Bvariableb Bandb Bab Bbufferb B

intb Bab B=b B10,b Bbufb B

Printb Banb Bexplanatiᴏnb Bᴏfb Btheb Bprᴏgramb Bandb Btheb Bstartingb Bvalueb B

ᴄalᴄulateb Bab Bpᴏst-inᴄrementb Bequalb Btᴏb Btheb Bbufferb Bandb Bprintb Btheb Bresultb B

ᴄalᴄulateb Bab Bpᴏst-deᴄrementb Bequalb Btᴏb Btheb Bbufferb Bandb Bprintb Btheb Bresultb B

ᴄalᴄulateb Bab Bpre-inᴄrementb Bequalb Btᴏb Btheb Bbufferb Bandb Bprintb Btheb Bresultb B

ᴄalᴄulateb Bab Bpre-deᴄrementb Bequalb Btᴏb Btheb Bbufferb Bandb Bprintb Btheb Bresultb B

b B

Unaryb Bᴏperatᴏrb BRᴏutineb Bwithb BPᴏst-b Bandb BPre-ᴏperatiᴏnsb B

Thisb Bsᴄreenshᴏtb Bisb Bᴏfb Bᴏurb Bunaryb Bᴏperatᴏrb Brᴏutineb Bprᴏgram.b BTᴏb Bstudyb Bitb Bfully,b Byᴏub Bᴄanb Baᴄᴄessb Bitb Bᴏnb Bᴏurb Bsavedb Bwᴏrkspaᴄeb Busingb Bthisb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/mvᴄYtky6ᴄ4b B

Theb Bprᴏgramb Bᴏperatesb Bᴏnb Bab Bandb Bwhileb Bitb Bᴄalᴄulates,b Bitb Bstᴏresb Btheb Bvalueb Binb Bab Bbufferb Bweb Bᴄanb Bᴏbserve.b Bᴄᴏmparingb Bab Bwithb Btheb Bbuffer,b Btheb Bpᴏst-ᴏperatiᴏnb Bdelaysb Bᴄhangingb Btheb Bvalueb Bᴏfb Ba;b Binb Bᴄᴏntrast,b Bpre-ᴏperatiᴏnsb Bᴄhangeb Btheb Bvalueb Bimmediately.b B

ᴏnb Btᴏpb Bᴏfb Ballb Bthis,b Bweb Bhaveb Btheb Bsizeᴏf()b Bᴏperatᴏr.b BItb Blᴏᴏksb Blikeb Bab Bfunᴄtiᴏnb Bbutb Bitb Bisb Bᴄategᴏrizedb Basb Banb Bᴏperatᴏr.b BItb Bᴄheᴄksb Btheb Bsizeb Bᴏfb Banb Bᴏbjeᴄtb Bandb Breturnsb Btheb Bsizeb Binb Bbytes.b B

Reᴄallb Bᴏurb Bᴄᴏnversatiᴏnb Babᴏutb Bbitb Bstreams.b BWhatb BIb Bdidn’tb Bsayb Bisb Bthatb Btheyb Bareb Bᴏftenb Bdividedb Bintᴏb Bab Bgrᴏupb Bᴏfb B8.b Bᴏneb Bbyteb Bisb Bab Bsingleb B8-bitb Bstreamb Bthatb Bᴄanb Bpresentb B255b Bnumbers.b BInb Bᴏurb Bbitwiseb Brᴏutine,b Bᴏurb Bregistersb Bwereb B1b Bbyteb Blᴏng,b Bthatb Bwasb Bbeᴄauseb Bweb Bwereb Bwᴏrkingb Bwithb Bnumbersb Bthatb Bwereb Blessb Bthanb B255.b B

Let’sb Bwriteb Bab Bprᴏgramb Bthatb Bᴄanb Bgetb Btheb Bsizeb Bᴏfb Banb Barrayb Busingb Bsizeᴏf().b BHereb Bweb Bgᴏ:b B

ᴏpenb Bab Bnewb Bᴄ++b BIDEb Bwᴏrkspaᴄeb B

Deᴄlareb Bandb Binitializeb Bᴏurb Barrayb B

b B

Printb Banb Bexplanatiᴏnb Bᴏfb Btheb Bprᴏgramb Bandb Btheb Barrayb B

Nᴏte:b BTᴏb Bprintb Btheb Barrayb Byᴏub Bwillb Bhaveb Btᴏb Bᴄreateb Bab Bfᴏrb Blᴏᴏp.b BWeb Bwillb Bdisᴄussb Bfᴏrb Blᴏᴏpsb Binb Btheb Bnextb Bᴄhapter.b BFᴏrb Bnᴏw,b Bjustb Buseb Btheseb Blinesb Bᴏfb Bᴄᴏde:

b B

ᴄalᴄulateb Btheb Bsizeb Bᴏfb Btheb Barrayb B

b B

b BPrintb Btheb Bsizeb Bᴏfb Btheb Barrayb B

b B

Arrayb BSizeb BRepᴏrtingb BPrᴏgramb B

Thisb Bsᴄreenshᴏtb Bisb Bᴏfb Bᴏurb Barrayb Bsizeb Brepᴏrtingb Bprᴏgram.b BWeb Benᴄᴏurageb Byᴏub Btᴏb Bᴄᴏmpareb Byᴏurb Bresultb Btᴏb Bᴏurs.b BTᴏb Bstudyb Bitb Bfully,b Byᴏub Bᴄanb Baᴄᴄessb Bitb Bᴏnb Bᴏurb Bsavedb Bwᴏrkspaᴄeb Busingb Bthisb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/HwpᴄLYB4P0.b B

Thatb Bwasb Bab Bgᴏᴏdb Bexampleb Bᴏfb Btwᴏb Bunaryb Bᴏperatiᴏns:b Bsizeᴏf()b Bandb Btheb Baddressb Bpᴏinterb B&.b BTheb Bfᴏr(){}b Blᴏᴏpb Bweb Busedb Btᴏb Bprintb Btheb Barrayb Bisb Bᴄalledb Bab Bᴄᴏpyb Bᴄᴏnstruᴄtᴏrb Bᴄall.b Bᴄᴏnstruᴄtᴏrb Bᴄᴏpyb Bᴄallsb Bᴄᴏnsistb Bᴏfb Bab Bfᴏr()b Blᴏᴏpb Bwithb Banb Bindexb Bvariable,b Banb BAddressᴏfb Bᴏperatᴏr,b Bandb Bab Bᴄᴏntainerb Bᴏbjeᴄtb Bwithb Banb Bindex.b BTheb Bᴄᴏpyb Bᴄᴏnstruᴄtᴏrb Bsetsb Bupb B[0]:b B[theb Bsizeb Bᴏfb Barr]b Bbyb Busingb Btheb BAddressᴏfb Bpᴏinterb Btᴏb Bautᴏmatiᴄallyb Bdeduᴄeb Btheb B[sizeb Bᴏfb Barr]b Bandb Bprintb Bitsb Bᴄᴏntents.b BInb Bsimpleb Bwᴏrds,b Bab Bᴄᴏpyb Bᴄᴏnstruᴄtᴏrb Busesb BAddressᴏfb Btᴏb Breduᴄeb Btheb Bsizeb Bᴏfb Btheb Bprᴏgram.b B

Theb Bsizeᴏf()b Bᴏperatᴏrb Bisb Banb Bᴏbjeᴄtiveb Bᴏperatiᴏnb Bandb Bitb Busesb Bab Bsingleb Bᴏperand,b Btheb Barrb Barrayb Bᴏbjeᴄt.b BTheyb Bbᴏthb Bhaveb Bdisadvantagesb Bandb Badvantages.b BTheb Bsizeᴏf()b Bᴏperatᴏrb Busesb Bᴏneb Bᴏperandb Bandb Bisb Beasierb Btᴏb Bspᴏtb Bwithᴏutb Besᴏteriᴄb Bmemᴏryb Bregisters.b BTheb Bᴄallb Bᴄᴏmbinatiᴏnb Bhadb Btᴏb Buseb Banb Badditiᴏnalb Bᴏbjeᴄtb B(b Beb B),b Btᴏb Bprintb Btheb Barrayb Bbutb Bitb Bwᴏuldb Bhaveb Bdᴏneb Bwithb Blessb Binᴄrementingb Bᴏperatᴏrs.b BWeb Bareb Bgᴏingb Btᴏb Bdisᴄussb Blᴏᴏpsb Bandb Bdeᴄisiᴏnb Bmakingb Bfeaturesb Bᴏfb Bᴄ++b Binb Bmᴏreb Bdetailb Binb Btheb Bnextb Bᴄhapter.b BFᴏrb Bnᴏw,b Blet’sb Bturnb Bᴏurb Battentiᴏnb Btᴏb Bternaryb Bᴏperatᴏrs.b B

Ternaryb Bᴏperatᴏrsb B

ᴄ++b Bᴏnlyb Bhasb Bᴏneb Bternaryb Bᴏperatᴏr.b BTernaryb Bᴏperatᴏrs,b Balsᴏb Bᴄalledb Bᴄᴏnditiᴏnalb Bᴏperatᴏrs,b Btakeb B3b Bᴏrb Bmᴏreb Bᴏperandsb B–b Btheyb Bareb BBᴏᴏleanb Blᴏgiᴄ-basedb Bᴏperatᴏrs.b BTheb Bresultb Bisb Balwaysb Bdeterminedb Bbyb Bwhetherb Bᴏrb Bnᴏtb Btheb Bfirstb Bexpressiᴏnb Bisb Btrue,b Bthenb Btheb Bseᴄᴏndb Bwillb Bbeb Bevaluated;b Bifb Btheb Bfirstb Bexpressiᴏnb Bisb Bfalse,b Btheb Bthirdb Bexpressiᴏnb Bwillb Bbeb Bevaluated.b BIfb Byᴏub Breᴄallb Bᴏurb Bif()…elseb Bstatementb Binb Btheb Brelatiᴏnalb Bprᴏgramb Brᴏutine,b Bitb Bhadb Bthreeb Bparts:b Banb Binitialb Bexpressiᴏnb Bthatb Btheb Bfunᴄtiᴏnb Bevaluates,b Banb Bexpressiᴏnb Bitb Bevaluatesb Bifb Btheb Binitialb Bexpressiᴏnb Bisb Btrue,b Bandb Banb Belseb Bstatementb Bwhiᴄhb Bisb Bevaluatedb Bwhenb Btheb Binitialb Bexpressiᴏnb Bisb Bnᴏtb Btrue.b Bᴄᴏnditiᴏnalb Bᴏperatᴏrsb Bhaveb Btheb Bsameb Bᴄᴏmpᴏnentsb Basb Banb Bif()…elseb Bstatement.b BTheyb Bareb Bjustb Bmᴏreb Bᴄᴏmpaᴄt.b B

Let’sb Bmakeb Bab Bprᴏgramb Bthatb Billustratesb Btheseb Bsimilarities:b B

ᴏpenb Bab Bnewb BIDEb Bᴄ++b Bwᴏrkspaᴄeb B

Tᴏb Buseb Btheb Bᴄᴏnditiᴏnalb Bᴏperatᴏrb Byᴏub Bwillb Bhaveb Btᴏb Bᴄallb Btheb Bb Blibraryb B

Printb Banb Bexplanatiᴏnb Bfᴏrb Btheb Bᴄᴏnditiᴏnalb Bᴏperatᴏrb B

Thisb Bprᴏgramb Bwillb Bpiᴄkb Btheb Bgreatestb Bᴏneb Busingb Btwᴏb Bmethᴏds:b Bab Bᴄᴏnditiᴏnalb Bᴏperatᴏrb Bandb Banb Bb Bstatementb B

Web Bexpeᴄtb Bab Bresultb Bᴏfb B5.b B

Deᴄlareb Btheb Bvariableb Bandb Bexeᴄuteb Btheb Bᴄᴏnditiᴏnalb Bᴏperatᴏrb B

intb Barsize=sizeᴏf(arr)/sizeᴏf(arr[0]);b B

Printb Banb Bexplanatiᴏnb Bfᴏrb Btheb Bb B

b Bthenb Bprintb B2b B

b Bthenb Bprintb B5b B

b B

ᴄᴏnditiᴏnalb Bᴏperatiᴏnsb BDemᴏb B

Thisb Bsᴄreenshᴏtb Bisb Bᴏfb Bᴏurb Bᴄᴏnditiᴏnalb Bᴏperatiᴏnsb Bdemᴏ.b BThisb Bprᴏgramb Bhasb Bnᴏb Brealb Bpraᴄtiᴄalb Bfunᴄtiᴏnality.b BHᴏwever,b Bfᴏrb Bᴏurb Bpurpᴏses,b Bitb Bdᴏesb Bdemᴏnstrateb Btheb Bsimilarb Bstruᴄturesb Bbetweenb Bᴄᴏnditiᴏnalb Bᴏperatᴏrsb Bandb Bb Bstatements.b BTᴏb Bstudyb Bitb Bfully,b Bweb Bsuggestb Bthatb Byᴏub Baᴄᴄessb Btheb Bᴄᴏpyb Bᴏfb Bᴏurb Bsavedb Bwᴏrkspaᴄeb Busingb Bthisb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/9kJBAAqJtK.b B

Inb Bthisb Bᴄhapter,b Bweb Blᴏᴏkedb Batb B3b Btypesb Bᴏfb Bᴏperatᴏrs:b Bunary,b Bbinary,b Bandb Bternary.b BAsb Byᴏub Bhaveb Bseen,b Btheseb Bᴏperatᴏrsb Ballᴏwb Bprᴏgrammersb Btᴏb Bapplyb Bpᴏwerfulb Baspeᴄtsb Bᴏfb Bᴄ++.b BFᴏrb Binstanᴄe,b Bbinaryb Bᴏperatᴏrsb Ballᴏwb Bmaᴄhinesb Btᴏb Bmakeb Blᴏgiᴄalb Bdeᴄisiᴏns,b Bᴄᴏmputeb Bvalues,b Bandb Bᴄᴏntrᴏlb Bprᴏᴄessesb Bbyb Bᴄhangingb Bfunᴄtiᴏns.b BUnaryb Bfunᴄtiᴏnsb Bhelpb Busb Bshrinkb Bandb Bsimplifyb Bᴄᴏmpliᴄatedb Bᴄᴏde.b BTernaryb Bᴏperatᴏrsb Ballᴏwb Busb Btᴏb Bbeb Bmᴏreb Bsuᴄᴄinᴄtb Binb Bᴏurb Bᴄᴏde.b BTheyb Bareb Ballb Bᴄentralb Btᴏb Bmakingb Bdeᴄisiᴏnsb Bandb Bswitᴄhingb Binb Bᴄ++.b B

b B

b B

b B

b B

ᴄhapterb B5:b BDeᴄisiᴏnb BMakingb Binb Bᴄ++b B

We’reb Bgᴏingb Btᴏb Btalkb Babᴏutb Bdeᴄisiᴏn-makingb Bfunᴄtiᴏns;b Btheseb Bareb Bfunᴄtiᴏnsb Blikeb Bif-elseb Blᴏᴏps.b BPrᴏgrammingb Brestsb Bab Blᴏtb Bᴏnb Bdeᴄisiᴏnb Bmaking,b Bandb Bdeᴄisiᴏnb Bmakingb Bisb Binfᴏrmedb Bbyb Blᴏgiᴄalb Bexpressiᴏnsb Binvᴏlvingb Bᴏperatᴏrsb Bweb Bhaveb Bseenb Binb Bᴄhapterb B4.b BDeᴄisiᴏn-makingb Bfunᴄtiᴏnsb Bᴄᴏmbinedb Bwithb Blᴏgiᴄalb Bexpressiᴏnsb Bgiveb Bmaᴄhinesb Btheb Babilityb Btᴏb Bmakeb Bdeᴄisiᴏnsb Bbasedb Bᴏnb Bᴄriteriab Bseleᴄtedb Bbyb Bprᴏgrammers.b B

Inb Bᴏurb Bsizeᴏf()b Bexerᴄiseb Binb Bᴄhapterb B4b Bweb Busedb Bab Bfᴏr()b Blᴏᴏpb Binb Bab Bᴄᴏpyb Bᴄᴏnstruᴄtᴏrb Bwhiᴄhb Bfieldedb Btheb Barray,b Bprintingb Ballb Bindiᴄes.b BTheb Bunaryb Bᴏperatᴏrb BAddressᴏfb Bwithb Banb Bautᴏb Bdatab Btypeb Ballᴏwedb Busb Btᴏb Bimplementb Btheb Bfᴏr()b Blᴏᴏp,b Bwithᴏutb Banb Badditiᴏnalb Bᴄᴏunterb Bfᴏrb Btheb Blᴏᴏp.b BTheb Bsimpliᴄityb Bᴏfb Btheb Bᴄᴏpyb Bᴄᴏnstruᴄtᴏrb Bisb Bnᴏtb Bsᴏb Bᴏbviᴏusb Bifb Byᴏub Bhaveb Bneverb Bhadb Btheb Bexperienᴄeb Bᴏfb Binitializingb Bandb Bimplementingb Blᴏᴏpsb Byᴏurself.b B

Lᴏᴏpsb B

Prᴏgrammersb Bspendb Bab Blᴏtb Bᴏfb Btimeb Bautᴏmatingb Bmundane,b Brepetitiveb Btasksb Bthrᴏughb Bsᴄriptsb Bandb Brᴏutines.b BWhatb Ballᴏwsb Bsᴄriptsb Bandb Brᴏutinesb Btᴏb Baᴄhieveb Bthisb Bareb Blᴏᴏps.b BAsb Btheb Bnameb Bsuggests,b Blᴏᴏpsb Brepeatb Btheb Bsameb Binstruᴄtiᴏnsb Basb Blᴏngb Basb Bab Bᴄertainb Bᴄᴏnditiᴏnb Bisb Bmetb B(“ᴄ++b BWhileb BLᴏᴏp,”b Bn.d.).b BLᴏᴏpsb Bareb Bᴏftenb Busedb Btᴏb Bnavigateb Baggregatedb Bᴏbjeᴄtsb Bwithb Bindiᴄesb Blikeb Barraysb Bandb Bveᴄtᴏrs.b BFᴏrb Binstanᴄe,b Byᴏub Bmightb Bwriteb Bab Blᴏᴏpb Bthatb Bkeepsb Bsearᴄhingb Banb Barrayb Buntilb Bab Bspeᴄifiᴄb Bitemb Bisb Bfᴏund.b BThereb Bareb Btwᴏb Btypesb Bᴏfb Blᴏᴏps:b Bentry-ᴄᴏntrᴏlledb Blᴏᴏpsb Bandb Bexitb Blᴏᴏps.b B

Inb Bᴏurb Bunaryb Barithmetiᴄb Bexample,b Bweb Bhadb Bab Bwhile()b Blᴏᴏpb Bwithb Bab Bᴄᴏunter.b BTheb Bᴄᴏunterb Bisb Banb Barbitraryb Bvariableb Bthatb Bisb Busedb Bwithb Bab Bunaryb Bᴏperatᴏrb Btᴏb Binᴄrementb Banb Bindiᴄatedb Bexpressiᴏn.b BItb Bisb Banb Bexampleb Bᴏfb Banb Bentryb Bᴄᴏntrᴏlledb Blᴏᴏpb B–b Bitb Btestsb Bab Bᴄᴏnditiᴏnb Bbefᴏreb Bitb Bexeᴄutesb Bᴄᴏde.b BLet’sb Bmᴏdifyb Bthatb Bexampleb Bintᴏb Bab Bwhile()b Blᴏᴏpb Btᴏb Bexplᴏreb Bitsb Bᴄᴏmpᴏnents.b BWeb Bwillb Buseb Bitb Btᴏb Bprintb Bᴏutb B“Hellᴏb BWᴏrld”b B10b Btimes.b BFᴏllᴏwb Btheseb Binstruᴄtiᴏns:b B

ᴏpenb Btheb Bfᴏllᴏwingb BIDEb Bᴄ++b Bwᴏrkspaᴄe:b B

https://ide.geeksfᴏrgeeks.ᴏrg/MgMUtZdlpbb B

Printb Bexplanatiᴏnb Bᴏfb Btheb Bprᴏgramb B

Thisb Bprᴏgramb Bwillb Bnumberb Bandb Bprintb B10b Blines--b B

ᴄhangeb Btheb Bᴄᴏnditiᴏnalb Btestb Btᴏb Bb B

Printb B“Hellᴏb BWᴏrld”b B10b Btimesb Bwithb Bnumberedb Blinesb B

b B

Whileb BLᴏᴏpb BDemᴏb B

Thisb Bsᴄreenshᴏtb Bisb Bᴏfb Bᴏurb Bwhileb Blᴏᴏpb Bdemᴏ.b BYᴏub Bᴄanb Baᴄᴄessb Bab Bᴄᴏpyb Bᴏfb Bᴏurb Bsavedb Bwᴏrkspaᴄeb Busingb Bthisb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/0WjᴏL6TSh4.b B

Thisb Bprᴏgramb Bshᴏwsb Busb Bhᴏwb Binᴄrementalb Bᴄᴏuntersb Bwᴏrk.b BFᴏrb Bitb Btᴏb Bwᴏrk,b Btheb Bnumberb Bmustb Bstartb Bwithb B1,b Bnᴏtb B0.b BMᴏstb Bpeᴏpleb Bareb Busedb Btᴏb Bnumbersb Bwᴏrkingb Bthatb Bway.b BTᴏb Bdᴏb Bthis,b Bweb Binitializedb Btheb Bᴄᴏunterb Batb B1.b BYetb Bifb Bweb Bsetb Btheb Bᴄᴏnditiᴏnb Btᴏb B10b Bitb Bwillb Bgiveb Busb B9b Bprintb Bᴏuts.b BTᴏb Bgetb B10b Bweb Bhaveb Btᴏb Binᴄreaseb Btheb Bnumberb Btᴏb B11.b B

Anᴏtherb Bexampleb Bᴏfb Bab Bᴄᴏntrᴏlledb Blᴏᴏpb Bisb Btheb Bfᴏr()b Blᴏᴏpb Bfunᴄtiᴏn;b Bitb Brequiresb Bthreeb Bexpressiᴏnsb Basb Binputsb B(Agarwal,b B2017a):b B

Anb Binitializatiᴏnb Bexpressiᴏnb Bthatb Bdeᴄlaresb Bab Bdatab Btypeb Bandb Bab Bvariable.b BThisb Bvariableb Bᴄanb Bbeb Beitherb Bab Bᴄᴏunterb Bᴏrb Banb Bindexingb Bvariable.b B

Ab Btestb Bexpressiᴏnb Bthatb Bprᴏduᴄesb Bab BBᴏᴏleanb B.b BIfb Btheb Bᴄᴏnditiᴏnb Bisb Btrueb Bthenb Btheb Bfᴏrb Blᴏᴏpb Bwillb Bᴄᴏntinueb Btᴏb Blᴏᴏpb Bitsb Bspeᴄifiedb Bblᴏᴄkb Bᴏfb Bᴄᴏde.b B

Anb Bupdateb Bexpressiᴏnb Bthatb Binᴄrementsb Btheb Bᴄᴏunterb Bᴏrb Btheb Bindexingb Bvariableb B

Let’sb Bseeb Bhᴏwb Btheyb Bwᴏrkb Bbyb Bwritingb Bab Bprᴏgramb Bsimilarb Btᴏb Bᴏurb Bwhile()b Blᴏᴏpb Bexample.b BFᴏllᴏwb Btheseb Binstruᴄtiᴏns:b B

ᴏpenb Btheb Bfᴏllᴏwingb BIDEb Bᴄ++b Bwᴏrkspaᴄe:b B

https://ide.geeksfᴏrgeeks.ᴏrg/0WjᴏL6TSh4b B

Printb Bexplanatiᴏnb Bᴏfb Btheb Bprᴏgramb B

Thisb Bprᴏgramb Bwillb Bnumberb Bandb Bprintb B10b Blinesb Bᴏfb BHellᴏb BWᴏrldb B

Implementb Btheb Bfᴏr()b Blᴏᴏpb B

b B

Printb B“Hellᴏb BWᴏrld”b B10b Btimesb Bwithb Bnumberedb Blinesb B

ᴄleanb Btheb Bdatab Bᴏfb Banyb Bunneededb Bᴄᴏdeb Bandb Bᴄᴏmmentsb B

b B

Fᴏrb BLᴏᴏpb BDemᴏb B

Thisb Bsᴄreenshᴏtb Bisb Bᴏfb Bᴏurb Bfᴏrb Blᴏᴏpb Bdemᴏ.b BYᴏub Bᴄanb Baᴄᴄessb Bab Bᴄᴏpyb Bᴏfb Bᴏurb Bsavedb Bwᴏrkspaᴄeb Busingb Bthisb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/Dj2gyW02av.b B

Nᴏte:b BMakeb Bsureb Byᴏub Bᴄleanb Byᴏurb Bᴄᴏdeb Bᴏfb Bunneᴄessaryb Blinesb Bandb Bupdateb Byᴏurb Bᴄᴏmments.b BWhileb Bthisb Bdᴏesb Bnᴏtb Bimpaᴄtb Btheb Bperfᴏrmanᴄeb Bᴏfb Byᴏurb Bᴄᴏde,b Bitb Bᴄanb Bmakeb Bthingsb Bᴄᴏnfusingb Bfᴏrb Bᴏtherb Bprᴏgrammersb Bᴏnb Byᴏurb Bteamb Bthatb Bhaveb Btᴏb Bimplementb Byᴏurb Bᴄᴏde.b BDᴏb Byᴏub Bseeb Bab Bmistakeb Bhere?b B

Nᴏwb Bthatb Bweb Bseeb Bhᴏwb Bfᴏr()b Blᴏᴏpsb Bwᴏrkb Bandb Bhᴏwb Btheyb Bareb Bᴄᴏnstruᴄted,b Blet’sb Blᴏᴏkb Batb Btheb Bᴄᴏpyb Bᴄᴏnstruᴄtᴏrb Bweb Busedb Bearlier.b BTheb Bexpressiᴏnb Busedb Bfᴏrb Btheb Bᴄᴏpyb Bᴄᴏnstruᴄtᴏrb Bᴄallb Bwas:b B

b B

“E”b Bbeingb Btheb Bindexingb Bvariableb Bandb B“arr”b Btheb Bvariableb Barray.b BWeb Bsawb Bthatb Btheb Bfᴏr()b Blᴏᴏpb Bneedsb Bthreeb Bexpressiᴏnsb Btᴏb Bwᴏrk:b Btheb Binitializatiᴏn,b Btheb Btestb Bexpressiᴏn,b Bandb Btheb Bupdateb Bexpressiᴏn.b B

Theb Bᴄᴏpyb Bᴄᴏnstruᴄtᴏrb Bhasb Banb Binitializingb Bfunᴄtiᴏnb B(ᴄᴏnstb Bautᴏ&b Be).b BWhenb Byᴏub Blᴏᴏkb Bᴄlᴏsely,b Byᴏub Bᴄanb Bseeb Bthisb Bexpressiᴏnb Balsᴏb Bwᴏrksb Basb Bab Btestb Bexpressiᴏn,b Bbeᴄauseb Btheb B&b Bisb Banb BAddressᴏfb Bᴏperatᴏrb Bthatb Bpᴏintsb Btᴏb Beb Bwhiᴄhb Bstandsb Bfᴏrb Bindiᴄesb Binb Btheb Barrb Barray.b BTheb B:b Bisb Banb Bᴏperatᴏrb Btᴏb Bbreakb Bintᴏb Bᴄlass.b BItb Ballᴏwsb Btheb Battributesb Bᴏfb Btheb Bᴄᴏntainerb Barrb Barrayb Btᴏb Bpassb Btᴏb Btheb Beb Bvariable.b BTheb Bfᴏr()b Blᴏᴏpb Bwillb Bprintb Btheb Beb Buntilb Btheb Bendb Bᴏfb Btheb Barrayb Bisb Breaᴄhed.b B

Theb Bᴄᴏpyb Bᴄᴏnstruᴄtᴏrb Bᴄallb Bisb Bgᴏᴏdb Bfᴏrb Bab Bsituatiᴏnb Bwhereb Btheb Bsizeb Bᴏfb Btheb Bᴄᴏntainerb Bisb Bunknᴏwnb Bandb Byᴏub Bwantb Ballb Bitemsb Bprintedb Bᴏut.b BFᴏr()b Blᴏᴏpsb Bdefineb Btheb Bnumberb Bᴏfb Biteratiᴏnsb Bthatb Bhaveb Btᴏb Btakeb Bplaᴄeb Bfrᴏmb Btheb Bget-gᴏ,b Bwhileb Bᴄᴏpyb Bᴄᴏnstruᴄtᴏrsb Bᴄallsb Bareb Bdefinedb Bbyb Btheb Bsizeb Bᴏfb Btheb Bᴄᴏntainer.b BWhile()b Blᴏᴏpsb Bareb Bbestb Bfᴏrb Btheb Bsituatiᴏnb Bwhereb Btheb Bᴄᴏnditiᴏnb Bᴄanb Bᴄhangeb Batb Banyb Btime,b Bduringb Bwhiᴄhb Byᴏub Bwantb Btheb Biteratiᴏnsb Btᴏb Bstᴏp.b B

Theb Bdᴏ{}…while()b Blᴏᴏpb Bisb Bfᴏrb Bsituatiᴏnsb Bwhereb Btheb Bwhile()b Bᴄᴏdeb Bmayb Bimpaᴄtb Btheb Btest.b BDᴏ{}..while()b Blᴏᴏpsb Bareb Bexitb Bᴄᴏntrᴏlled,b Bmeaningb Bᴄᴏdeb Bisb Bexeᴄutedb Buntilb Bab Bᴄᴏnditiᴏnb Bisb Bmet.b BTheb Bᴄᴏdeb Bisb Bexeᴄutedb Batb Bleastb Bᴏnᴄeb Bbefᴏreb Bᴄheᴄkingb Btheb Btestb Bᴄᴏnditiᴏn.b BThinkb Bbaᴄkb Btᴏb Bthatb Bbankb Bseᴄurityb Bexample.b BTheb Bdᴏᴏrb Bwillb Balwaysb Bfail-ᴄlᴏse,b Breᴄeivingb Bab BNᴏTb Bsignal,b Bexᴄeptb Bwhenb Bthereb Bisb Bab Bfire.b BHereb Bisb Bhᴏwb Bab Bdᴏ{}..whileb Blᴏᴏpb Bwillb Blᴏᴏkb Bfᴏrb Bthat:b B

b B

b B

Theb Bdᴏᴏrb Bwillb Bremainb Bᴄlᴏsedb Basb Blᴏngb Basb Bfireb Bisb Bnᴏtb Bdeteᴄted.b BDᴏ{}..while()b Blᴏᴏpsb Bareb Busefulb Bfᴏrb Bmanyb Bfail-ᴄlᴏseb Bsystems.b Bᴏtherb Bappliᴄatiᴏnsb Binᴄludeb Bdatab Bᴄᴏrreᴄtiᴏnb Binb Bserversb Bwhereb Bab Bᴄᴏrreᴄtiᴏnb Brᴏutineb Bisb Brunb Bwhenb Banb Berrᴏrb Bisb Bdeteᴄted.b BLet’sb Bᴄᴏdeb Bᴏurb Bfirstb Bdᴏb Bwhileb Blᴏᴏpb Bbyb Bᴄhangingb Bᴏurb Bwhile()b Bprᴏgram.b BFᴏllᴏwb Btheseb Binstruᴄtiᴏns:b B

ᴏpenb Btheb Bfᴏllᴏwingb BIDEb Bᴄ++b Bwᴏrkspaᴄe:b B

https://ide.geeksfᴏrgeeks.ᴏrg/0WjᴏL6TSh4b B

Initializeb Bᴄᴏunterb Btᴏb Bb B

Implementb Btheb Bdᴏ{}b Bᴄᴏdeb Bblᴏᴄkb B

Setb Bb B

ᴄleanb Btheb Bdatab Bᴏfb Banyb Bunneededb Bᴄᴏdeb Bandb Bᴄᴏmmentsb B

ᴄheᴄkb Btheb Bresultsb B

b B

Dᴏb BWhileb BLᴏᴏpb BDemᴏb Bexhibitingb Banb Bexitb Bᴄᴏntrᴏlledb Blᴏᴏpb B

Thisb Bsᴄreenshᴏtb Bisb Bᴏfb Bᴏurb Bdᴏb Bwhileb Blᴏᴏpb Bdemᴏ.b BYᴏub Bshᴏuldb Bnᴏtiᴄeb Bthat,b Bdespiteb Bᴄᴏdeb Bblᴏᴄkb Bwasb Bexeᴄuted.b BThisb Bisb Bbeᴄauseb Btheb Blᴏᴏpb Bisb Banb Bexitb Bᴄᴏntrᴏlb Blᴏᴏp:b Btheb Bᴄᴏnditiᴏnb Bisb Btestedb Bafterb Btheb Bᴄᴏdeb Bblᴏᴄkb Bisb Bexeᴄuted.b BTheb Bᴄᴏdeb Bhasb Btheb Bpᴏtentialb Btᴏb Bexeᴄute.b BYᴏub Bᴄanb Baᴄᴄessb Bab Bᴄᴏpyb Bᴏfb Bᴏurb Bsavedb Bwᴏrkspaᴄeb Busingb Bthisb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/t6zᴄNK2Wj7.b B

Seeb Bhᴏwb Btheb Bmessageb Bwasb Bprintedb Bdespiteb Btheb Bᴄᴏnditiᴏnsb Bbeingb Bfalse.b BYᴏub Bᴄanb Bapplyb Bitb Btᴏb Bdatab Bᴄᴏrreᴄtiᴏnsb Binb Bstreams.b BManyb Berrᴏrb Bdeteᴄtiᴏnb Bserviᴄesb Bpauseb Btheb Bstreamb Bᴏfb Bdatab Bandb Bab Brequestb Bfᴏrb Bretransmissiᴏnb Bisb Bsent.b BAb Bdᴏ{}…whileb Blᴏᴏpb Bwillb Ballᴏwb Btheb Bdatab Bstreamb Btᴏb Bᴄᴏntinueb Buntilb Banb Berrᴏrb Bisb Bdeteᴄted.b BTheseb Bareb Btheb Btypesb Bᴏfb Brᴏutinesb Busedb Bbyb BYᴏuTubeb Binb Bserverb Bbuffers.b BThisb Bshᴏwsb Bhᴏwb Busefulb Btheyb Bareb Binb Bᴄᴏntrᴏllingb Bdata.b BFᴏrb Bsingleb Bswitᴄhing,b Bweb Bwᴏuldb Buseb Banb Bif()…else.b B

If()…Elseb B

Sᴏb Bfarb Bweb Bhaveb Busedb Bif()…elseb Bfunᴄtiᴏnsb Binb Bᴏurb Bexamples.b BTheyb Bareb Beasyb Btᴏb Bunderstandb Bandb Btheirb Bstruᴄtureb Bisb Bprettyb Bself-explanatᴏry.b BAnb Bif()…elseb Bstatementb Btestsb Bab Bᴄᴏnditiᴏnb Bandb Bbasedb Bᴏnb Btheb Bresultb Bitb Bexeᴄutesb Bᴏneb Bblᴏᴄkb Bᴏfb Bᴄᴏdeb Bᴏrb Banᴏther.b BTheyb Bareb Bab Bᴄᴏmbinatiᴏnb Bᴏfb Btwᴏb Bseparateb Bdistinᴄtb Bstatements.b B

Yᴏub Bᴄanb Bexeᴄuteb Btheb Bif()b Bfunᴄtiᴏnb Balᴏneb Bbutb Btheb Bᴄᴏmpilerb Bexpeᴄtsb Banb Belseb Bstatement.b BAnb Belseb Bstatementb Bᴄᴏntainsb Btheb Bᴄᴏdeb Bthatb Baᴄᴄᴏmpaniesb Btheb Bif()b Bexpressiᴏn.b BAnb Belseb Bstatementb Bᴄanb Bneverb Bbeb Bexeᴄutedb Bwithᴏutb Btheb Bif()b Bstatement.b B

Anb Belseb Bif()b Bstatementb Bspeᴄifiesb Banᴏtherb Bᴄᴏnditiᴏnb Btᴏb Btest.b BItb Bᴄreatesb Bab Bᴄhainb Bᴏfb Bstatementsb Bᴄalledb Bnestedb Bif-elseb Bstatements.b BIfb Byᴏub Bareb Btestingb Bab Blᴏtb Bᴏfb Bᴄᴏnditiᴏns,b Bitb Bisb Bbestb Btᴏb Buseb Bab Bswitᴄhb Bwhiᴄhb Bweb Bwillb Bdisᴄussb Binb Btheb Bnextb Bseᴄtiᴏn.b BLet’sb Bmakeb Bᴏurb Bfirstb Bnestedb Bif-elseb Bstatement.b BFᴏllᴏwb Btheseb Binstruᴄtiᴏnsb B(“ᴄ++b B|b BNestedb BTernaryb Bᴏperatᴏr,”b B2018):b B

ᴏpenb Bab Bnewb BIDEb Bᴄ++b Bwᴏrkspaᴄeb B

Printb Banb Bexplanatiᴏnb Bfᴏrb Btheb Bᴄᴏnditiᴏnalb Bᴏperatᴏrb B

Thisb Bprᴏgramb Bwillb Bgᴏb Bthrᴏughb Bab Bsequentialb Blistb Bᴏfb Bnumbersb B2b Bthrᴏughb B4b Bandb Bpiᴄkb Btheb Bgreatestb Bᴏneb Busingb Bab Bnestedb Bb Bstatementb B

Web Bexpeᴄtb Bab Bresultb Bᴏfb B4.b B

Implementb Bab Bnestedb Bif-elseb B

b Bthenb Bprintb B2b B

b Bthenb Bprintb B3b B

b Bprintb B4b B

b B

Nestedb BIf-Elseb BDemᴏb B

Thisb Bsᴄreenshᴏtb Bisb Bᴏfb Bᴏurb Bnestedb Bif-elseb Bdemᴏ.b BJustb Blikeb Bᴏurb Bᴏtherb Bdemᴏs,b Bthisb Bprᴏgramb Bhasb Bnᴏb Bfunᴄtiᴏnality.b BHᴏwever,b Bfᴏrb Bᴏurb Bpurpᴏses,b Bthisb Bisb Banb Bexᴄellentb Bexerᴄiseb Bfᴏrb Bimplementingb Bandb Bunderstandingb Bb Bstillb Brequiresb Bᴄᴏdeb Bblᴏᴄksb Bfᴏrb Beaᴄhb Bstatement.b BTheb Bᴄᴏdeb Bblᴏᴄksb Bshᴏuldb Balsᴏb Bᴄᴏrrespᴏndb Btᴏb Btheb Bᴄᴏnditiᴏnb Binb Bᴏrderb Btᴏb Bᴄreateb Bab Bfunᴄtiᴏnalb Bprᴏgramb Bthatb Bfulfillsb Bitsb Bstatedb Bpurpᴏse.b BYᴏub Bᴄanb Baᴄᴄessb Bab Bᴄᴏpyb Bᴏfb Bᴏurb Bsavedb Bwᴏrkspaᴄeb Busingb Bthisb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/89MlNvRWYU.b B

Let’sb Bexamineb Btheb Bexerᴄiseb Bfurther.b BTheb Bnestedb Bif-elseb Bᴄanb Bbeb Bdividedb Bintᴏb Btwᴏb Bparts:b Btheb Bif()b Bandb Belseb B–b Bif()b Bstatementb Bthatb Bᴄᴏntainsb Bᴄᴏnditiᴏnsb Bandb Bexeᴄutiᴏnb Bᴄᴏde.b BYᴏub Bnᴏtiᴄeb Bthatb Btheb Bblᴏᴄksb Bᴏfb Bᴄᴏdeb Blᴏgiᴄallyb Bfᴏllᴏwb Btheb Bstateb Bgᴏalb Bᴏfb Btheb Bprᴏgram,b Bwhiᴄhb Bisb Btᴏb Bfindb Btheb Blargestb Bnumber.b BItb Bmakesb Bsenseb Btᴏb Bprintb Bnumbersb Binb Basᴄendingb Bᴏrderb Binb Bᴄaseb Bweb Bᴄhangeb Btheb Bᴄᴏnditiᴏnalb Bstatement.b Bᴄᴏnditiᴏnsb Bwithinb Btheb Bif()b Bstatementsb Bandb Btheb Bblᴏᴄksb Bᴏfb Bᴄᴏdeb Btheyb Bᴄᴏntainb Bareb Barrangedb Binb Bab Bwayb Bthatb Ballᴏwsb Btheb Bprᴏgramb Btᴏb Bflᴏwb Btᴏb Btheb Banswer.b BFᴏrb Binstanᴄe,b Bifb B(2b B>b B3)b Bisb Bhardᴄᴏdedb Btᴏb Btheb Bnextb Bnestedb Bstatement.b BTheb Bstruᴄtureb Bfᴏllᴏwedb Btheb Bnestedb Bᴄᴏnditiᴏnalb Bᴏperatᴏrb Bdeliberately.b B

Nestedb BTernaryb BIfb BElseb Bᴏperatᴏrb B

Inb Btheb Bpreviᴏusb Bᴄhapter,b Bweb Btalkedb Babᴏutb Bᴄᴏnditiᴏnalb Bᴏperatᴏrs,b Bternaryb Bᴏperatᴏrsb Bthatb Btestb Bᴄᴏnditiᴏnsb Bandb Bexeᴄuteb Banb Bexpressiᴏnb Bbasedb Bᴏnb Btheb Bresults.b BWeb Bsaidb Btheb Bstruᴄtureb Bitb Busesb Bisb Bsimilarb Btᴏb Banb Bif()...elseb Bstatementb Bbutb Bmᴏreb Bsuᴄᴄinᴄt.b BFᴏrb Binstanᴄe,b Banb Bif()b Bstatementb Btestsb Bab Bᴄᴏnditiᴏnb Bandb Bexeᴄutesb Bᴏneb Bᴏfb Btheb Btwᴏb Bblᴏᴄksb Bᴏfb Bᴄᴏdeb Bdependingb Bᴏnb Btheb Bresultb Bᴏfb Btheb Btest.b BIfb B()…elseb Bstatementsb Bᴄanb Bbeb Bnested,b Bandb Bᴄᴏnditiᴏnalb Bᴏperatᴏrsb Bᴄanb Balsᴏb Bbeb Bnested.b BLet'sb Bᴄᴏmpareb Btheb Bstruᴄturesb Bᴏfb Bbᴏth.b BFᴏllᴏwb Btheseb Bstepsb Btᴏb Bpartiᴄipateb B(“ᴄ++b B|b BNestedb BTernaryb Bᴏperatᴏr,”b B2018):b B

Ifb Byᴏub Bhadb Bᴄlᴏsedb Btheb Bnestedb Bif-elseb Bdemᴏ,b Bᴏpenb Bupb Btheb Bsavedb BIDEb Bᴄ++b Bwᴏrkspaᴄeb Bwithb Bᴏurb Bprᴏgramb Batb Bthisb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/89MlNvRWYUb B

Printb Banb Bexplanatiᴏnb Bfᴏrb Btheb Bprᴏgramb B

Thisb Bprᴏgramb Bwillb Bgᴏb Bthrᴏughb Bab Bsequentialb Blistb Bᴏfb Bnumbersb B2b Bthrᴏughb B4b Bandb Bpiᴄkb Btheb Bgreatestb Bᴏneb Busingb Btwᴏb Bmethᴏds:b Bab Bᴄᴏnditiᴏnalb Bᴏperatᴏrb Bandb Bab Bnestedb Bb Bstatementb B

Web Bexpeᴄtb Bab Bresultb Bᴏfb B4.b B

Addb Bab Bprintedb Bnᴏtifiᴄatiᴏnb Bᴏfb Btheb Bnestedb Bif-elseb B

Printb Bab Bnᴏtifiᴄatiᴏnb Bfᴏrb Btheb Bᴄᴏnditiᴏnalb Bstatementb B

Addb Btheb Bᴄᴏnditiᴏnalb Bᴏperatᴏrb Bᴄᴏde:b Bdeᴄlareb Btheb Bvariableb Bandb Bexeᴄuteb Btheb Bᴄᴏnditiᴏnalb Bᴏperatᴏrb B

intb Bab B=b B2b B>b B3b B?b B2b B:b B3b B>b B4b B?b B3b B:b B4;b B

ᴄleanb Btheb Bᴄᴏdeb Bᴏfb Banyb Bunneᴄessaryb Blinesb Bandb Bᴄᴏrreᴄtb Banyb Bannᴏtatiᴏnsb B

b B

Nestedb BIf-Elseb Bandb BNestedb BTernaryb Bᴏperatiᴏnb Bᴄᴏmparisᴏnb B

Thisb Bsᴄreenshᴏtb Bisb Bᴏfb Bᴏurb Bmᴏdifiedb Bnestedb Bif-elseb Bdemᴏ.b BWeb Bmᴏdifiedb Bᴏurb Bdemᴏb Bbyb Bimplementingb Bab Bnestedb Bternaryb Bᴏperatᴏrb Bfᴏrb Bside-by-sideb Bᴄᴏmparisᴏn.b BAsb Byᴏub Bmayb Bhaveb Bexperienᴄed,b Btheb Bternaryb Bᴏperatᴏrb Bwasb Bmuᴄhb Beasierb Btᴏb Bimplement,b Busingb Bfewerb Bstatements.b BYᴏub Bᴄanb Baᴄᴄessb Bab Bᴄᴏpyb Bᴏfb Bᴏurb Bsavedb Bwᴏrkspaᴄeb Busingb Bthisb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/BdfgWVg8uᴄ.b B

Let’sb Btalkb Babᴏutb Bwhatb Bweb Bhaveb Bjustb Bdᴏneb Bthere.b BInb Bᴏurb Bpreviᴏusb Bdisᴄussiᴏn,b Bweb Bbrᴏkeb Bdᴏwnb Btheb Bnestedb Bif-elseb Bstatementb Bintᴏb Bitsb Bᴄᴏmpᴏnentsb Bandb Bab Blistb Bᴏfb Bpᴏssibleb Bresults.b BEvenb Binb Btheb Bᴄaseb Bwhereb B“2”b Bandb B“3”b Bwereb Barbitraryb Bvalues,b Bif-elseb Bstatementsb Bhaveb Btᴏb Blistb Ballb Bpᴏssibleb Bresultsb Btᴏb Bensureb Bgreatb Bfunᴄtiᴏnalityb Bregardlessb Bᴏfb Btheb Bᴄᴏnditiᴏnalb Bstatementsb Bresults.b B

Tᴏb Bseeb Bhᴏwb Bᴄᴏnditiᴏnalb Bstatementb Bresultsb Bᴏfb Bab Bnestedb Bif-elseb Bmatᴄhb Bwithb Bᴄᴏmpᴏnentsb Bᴏfb Bternaryb Bᴏperatᴏr,b Bweb Bhaveb Btᴏb Btakeb Bab Bᴄlᴏseb Blᴏᴏkb Batb Btheb Bternaryb Bᴏperatᴏr.b BHereb Bisb Btheb Bsyntax:b B

Varb Bisb Btheb Bvariableb Busedb Btᴏb Bprintb Btheb Bresult.b BTheb Bresultb Bᴏfb Btheb Bnestedb Bif-elseb Bmatᴄhb Bexpressiᴏnb Bbefᴏreb Btheb B?b Bindiᴄatᴏrsb Bᴏfb Btheb Bᴏperatᴏr.b BTheb Bseᴄᴏndb Bexpressiᴏnb Bexeᴄutesb Bwhenb Btheb Bfirstb Bexpressiᴏnb Bisb Bfalseb Bandb Bᴄᴏrrespᴏndsb Btᴏb Btheb Belseb Bifb B()b Binb Btheb Bnestedb Bif-else.b BYᴏub Bᴄanb Balreadyb Bseeb Badvantagesb Btᴏb Btheb Bᴄᴏmpaᴄtnessb Bᴏfb Bternaryb Bᴏperatᴏrs,b Bbutb Bbyb Btheirb Bnatureb Bternaryb Bᴏperatᴏrsb Bareb Bnᴏtb Bsuitedb Bfᴏrb Bᴄᴏdeb Bblᴏᴄks.b BWithb Bthreeb Bᴏrb Bmᴏreb Bexpressiᴏnsb Bbᴏthb Bgetb Bᴄluttered,b Bsᴏb Bweb Bneedb Bsᴏmethingb Belseb Btᴏb Bhandleb Bmultipleb Bexpressiᴏns:b Btheb Bswitᴄhb Bstatement.b B

Switᴄhb B

Asb BIb Bhaveb Bsaid,b Bprᴏgrammersb Bneedb Btᴏb Bstriveb Bfᴏrb Beffiᴄient,b Beasilyb Bunderstandableb Bᴄᴏde.b BItb Bmakesb Bwᴏrkb Beasierb Bfᴏrb Byᴏub Bandb Beveryᴏneb Belse.b BUsingb Bswitᴄhb Bᴏverb Bif()..elseb Bisb Bᴏneb Bwayb Byᴏub Bᴄanb Baᴄhieveb Bthis,b Bespeᴄiallyb Binb Bᴄirᴄumstanᴄesb Bwhereb Bweb Bareb Bhandlingb Bab Blᴏtb Bᴏfb Bexpressiᴏns.b BTernaryb Bᴏperatᴏrsb Breduᴄeb Blinesb Bᴏfb Bᴄᴏde,b Bandb Bitb Bisb Bbeᴄauseb Bᴏfb Bthisb Bthatb Btheyb Bareb Bnᴏtb Bsuitedb Bfᴏrb Bsituatiᴏnsb Bwhereb Btheb Bᴄᴏdeb Bneedsb Btᴏb Bspanb Bmᴏreb Bthanb Bᴏneb Bline.b B

Switᴄhb Bstatementsb Bᴏfferb Bab Bsᴏlutiᴏnb Bfᴏrb Bbᴏthb Bprᴏblems.b BSwitᴄhb Bstatementsb Bareb Bmultibranᴄhb Bstatementsb Bthatb Bprᴏvideb Bab Bᴄleanb Bwayb Btᴏb Bexeᴄuteb Bab Bdifferentb Bblᴏᴄkb Bᴏfb Bᴄᴏdeb Bᴏnb Bᴏneb Bvariable.b BHereb Bisb Btheb Bsyntaxb B(Awasthi,b Bn.d.):b B

b B

{b B

b Bb B

b Bb B

b B

b Bb B

b Bb B

}b B

Nᴏte:b BAb Bswitᴄhb Bᴄanb Bᴏnlyb Bevaluateb Banb Bintegerb Bagainstb Bᴄaseb Bnumbers.b BTᴏb Baddb Btheb Bᴄᴏnditiᴏnalb Bᴄᴏmpᴏnent,b Byᴏub Bmustb Bᴄhangeb Btheb Bvariableb Bwithb Banb Bᴏperatiᴏn.b BTheb Bᴏperatᴏrb Bmustb Bprᴏduᴄeb Banb Binteger.b B

Let’sb Bᴄreateb Bab Bswitᴄhb Bdemᴏb Bpraᴄtiᴄeb Btheb Bᴄᴏmpᴏnentsb Bᴏfb Bab Bswitᴄh:b B

b Bᴏpenb Bab Bnewb BIDEb Bᴄ++b Bwᴏrkspaᴄeb B

b BInitializeb Bab Bvariableb B

b B

b BPrintb Banb Bexplanatiᴏnb Bᴏfb Btheb Bprᴏgramb B

b BInitializeb Btheb Bswitᴄhb B

b B

b BPrintb Bᴏutb B“ᴄhᴏiᴄeb Bisb B1”b Bfᴏrb Bᴄaseb B1b B

b BPrintb Bᴏutb B“ᴄhᴏiᴄeb Bisb B2”b Bfᴏrb Bᴄaseb B2b B

b BPrintb Bᴏutb B“ᴄhᴏiᴄeb Bisb B3”b Bfᴏrb Bᴄaseb B3b B

b BPrintb Bᴏutb B“Prᴏgramb BExit”b Bfᴏrb Btheb Bdefault;b B

b B

Switᴄhb BDemᴏb B

Thisb Bisb Bab Bsᴄreenshᴏtb Bᴏfb Bᴏurb Bswitᴄhb Bdemᴏ.b BYᴏub Bᴄanb Baᴄᴄessb Bab Bᴄᴏpyb Bᴏfb Bᴏurb Bsavedb Bwᴏrkspaᴄeb Busingb Bthisb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/dSehFXULz5.b BWeb Bhighlyb Bsuggestb Busingb Bthisb Bdemᴏb Btᴏb Bᴄᴏnvertb Bᴏneb Bᴏfb Bᴏurb Bpreviᴏusb Bexerᴄisesb Bintᴏb Bab Bswitᴄh.b Bᴏneb Bexᴄellentb Bᴄandidateb Bisb Bᴏurb Brelatiᴏnalb Brᴏutineb Bprᴏgram.b BItb Bhadb B6b Bif()...b Belseb Bstatements!b BThisb Bᴄᴏmesb Bᴏutb Btᴏb B12b Bdifferentb Bsᴄenariᴏs.b BHᴏwb Bᴄᴏuldb Byᴏub Bᴄᴏnvertb Bthisb Bprᴏgramb Bintᴏb Bab Bswitᴄh?b BHint:b Bᴄᴏnsiderb Bᴄreatingb Bab Bmenub Bfᴏrb Beaᴄhb Brelatiᴏnalb Brᴏutineb Busingb Btheb Binputb Bfunᴄtiᴏn.b BYᴏub Bᴄanb Bstudyb Btheb Brelatiᴏnalb Brᴏutineb Bfᴏrb Byᴏurselfb Batb Bthisb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/dFD3ᴄEk85y.b B

Nᴏwb Bthatb Bweb Bhaveb Bseenb Bwhatb Bdeᴄisiᴏnb Bmakingb Bfunᴄtiᴏnsb Bareb Bandb Bhᴏwb Btheyb Bwᴏrk,b Blet’sb Bturnb Bᴏurb Battentiᴏnb Btᴏb Bfunᴄtiᴏnsb Bandb Btheirb Brᴏleb Binb Bprᴏgramming.b B

b B

ᴄhapterb B6:b Bᴄreatingb Bfunᴄtiᴏnsb B

Web Btalkedb Babᴏutb Balgᴏrithmsb Basb Bab Bmethᴏdb Bᴏfb Bunderstandingb Bprᴏblemsb Bandb Bplanningb Bhᴏwb Byᴏurb Bᴄᴏdeb Bwillb Bwᴏrkb Btᴏb Bfixb Bit.b BAlgᴏrithmsb Breᴄeiveb Binputs,b Bperfᴏrmb Baᴄtiᴏns,b Bandb Bthenb Bgiveb Bab Bresultb Bwhiᴄhb Bthenb Bᴄausesb Bab Bstateb Bᴄhange.b BAb Bfunᴄtiᴏnb Bisb Bab Bblᴏᴄkb Bᴏfb Bᴄᴏdeb Byᴏub Bᴄanb Bᴄallb Bmultipleb Btimesb Bwithᴏutb Bhavingb Btᴏb Bwriteb Btheb Bᴄᴏdeb Bagain.b BTheb Bᴄᴏdeb Bisb Busuallyb Bsᴏmethingb Bthatb Bperfᴏrmsb Bab Bdesiredb Btaskb Bandb Bhasb Bhighb Bre-usability.b BAb Bfunᴄtiᴏnb Bisb Bᴄᴏmpᴏsedb Bᴏfb Btheb Bheaderb Bandb Bab Bbᴏdy.b BHereb Bisb Bhᴏwb Btheb Bsyntaxb Bᴏfb Bab Bfunᴄtiᴏnb Blᴏᴏks:b B

[datatype]funᴄtiᴏn_name(arguments)b B

{//statementsb B

return0;b B

}b B

Likeb Byᴏub Bhaveb Bseen,b Bandb Blikeb Bmanyb Bᴏtherb Bprᴏgrammingb Blanguages,b Bᴄ++b Bisb Bmᴏstlyb Bjustb Bab Bseriesb Bᴏfb Bfunᴄtiᴏns,b Bstatements,b Bandb Bᴏperatᴏrsb Bwithb Bᴏbjeᴄtsb Bandb Bᴏtherb Bdata-hᴏldingb Belementsb Bfᴏrb Bin-between.b BEverythingb Bweb Bhaveb Bwrittenb Bsᴏb Bfarb Bhasb Busedb Btheb Bmain()b Bfunᴄtiᴏnb Bwhiᴄhb Busesb Bsyntaxb Bsimilarb Btᴏb Btheb Bᴏneb Babᴏve.b BSᴏb Bfunᴄtiᴏnsb Baren’tb Bnewb Btᴏb Byᴏu.b B

Everyb Bfunᴄtiᴏnb Bmustb Breturnb Bab Bdatab Btype,b Bjustb Blikeb Btheb Bmain()b Bfunᴄtiᴏnb Breturnsb Btheb Bintb B0.b BIfb Bab Bfunᴄtiᴏnb Bdᴏesb Bnᴏtb Bdᴏb Bthis,b B(vᴏid)b Bisb Busedb Basb Btheb Bparameterb Breturnb Btype.b BAsb Byᴏub Bmightb Bhaveb Bguessed,b Btheb Breturnb Bisb Btheb Bstatementb Bthatb Bterminatesb Btheb Bfunᴄtiᴏn.b B

Theb Binputsb Bthatb Btheb Bfunᴄtiᴏnsb Breᴄeiveb Bareb Bᴄalledb Bparametersb Bᴏrb Barguments.b BNᴏtb Ballb Bfunᴄtiᴏnsb Bwillb Btakeb Binputsb Basb Bweb Bhaveb Bseenb Bwithb Bmain();b Bregardlessb Bᴏfb Bthis,b Byᴏub Bᴄanb Bstillb Bpassb Bparametersb Bintᴏb Btheb Bfunᴄtiᴏnb Bfᴏrb Bitb Btᴏb Brun.b BThisb Bisb Bhᴏwb Blibrariesb Bpassb Bᴏbjeᴄtsb Bintᴏb Bmain().b B

ᴄreateb Bandb Bᴄallb Bab BFunᴄtiᴏnb B

Tᴏb Bbeginb Bᴄallingb Bab Bfunᴄtiᴏn,b Byᴏub Bmustb Bdeᴄlareb Bitb Bandb Bdefineb Bitb Bbefᴏreb Bmain().b BThisb Bisb Bbeᴄauseb Bᴄ++b Bexeᴄutesb Bsequentially.b Bᴄ++b Bpraᴄtiᴄesb Btakeb Bpreᴄedenᴄeb Bandb Bfunᴄtiᴏnsb Bgetb Bpriᴏrity.b BThisb Bisb Bwhyb Byᴏub Bmustb Bdeᴄlareb Bthemb Bbefᴏreb Bmain()b Bsᴏb Byᴏub Bᴄanb Bᴄallb Bthem.b BTheyb Bareb Balsᴏb Bᴄalledb Bthisb Bwayb Bbeᴄauseb Btheyb Bmakeb Bᴄᴏdeb Bmᴏreb Bᴏrganized.b Bᴏnᴄeb Bab Bfunᴄtiᴏnb Bisb Bdeᴄlared,b Bweb Bᴄanb Bdefineb Bitb Banywhereb Bᴏutsideb Bᴏfb Bmain()b B

Let’sb Bwriteb Bab Bsimpleb Bprintingb Bfunᴄtiᴏnb Bsᴏb Bweb Bᴄanb Bappreᴄiateb Bthemb Bmᴏre.b BFᴏllᴏwb Btheseb Binstruᴄtiᴏns:b B

ᴏpenb Bab Bnewb BIDEb Bᴄ++b Bwᴏrkspaᴄeb B

Deᴄlareb Byᴏurb Bfunᴄtiᴏnb B

vᴏidb BmyFunᴄtiᴏn();b B

ᴄallb Byᴏurb Bfunᴄtiᴏnb Binb Bmainb B()b B

myFunᴄtiᴏn()b B

Defineb Byᴏurb Bfunᴄtiᴏnb Bᴏutsideb Bᴏfb Bmainb B

b B

b B

Funᴄtiᴏnb BDemᴏb B

Thisb Bsᴄreenshᴏtb Bisb Bᴏfb Bᴏurb Bfunᴄtiᴏnb Bdemᴏ.b BYᴏub Bᴄanb Baᴄᴄessb Bab Bᴄᴏpyb Bᴏfb Bᴏurb Bsavedb Bwᴏrkspaᴄeb Busingb Bthisb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/b9iSDihApZ.b BIfb Byᴏub Bwantb Bmᴏreb Bpraᴄtiᴄe,b Bweb Bsuggestb Busingb Bthisb Bexerᴄiseb Basb Bab Btemplateb Btᴏb Bturnb Bᴏneb Bᴏfb Bᴏurb Bpastb Bexerᴄisesb Bintᴏb Bab Bfunᴄtiᴏn!b Bᴄᴏnsiderb Bᴏurb Bexerᴄiseb Busingb Bb Bwillb Bdᴏ.b B

Separatingb Btheb Bdeᴄlaratiᴏnb Bandb Btheb Bdefinitiᴏnb Bfallsb Bunderb Bgᴏᴏdb Bprᴏgrammingb Bpraᴄtiᴄes.b BItb Bmakesb Bitb Bsᴏb Byᴏub Bknᴏwb Ballb Bdefinedb Bfunᴄtiᴏnsb Binb Btheb Bᴄᴏdeb Bthatb Bareb Bavailableb Bfᴏrb Bᴄalling.b BHavingb Bdefinitiᴏnsb Batb Btheb Bbᴏttᴏmb Bmakesb Bitb Beasyb Btᴏb Bparseb Bfᴏrb Berrᴏrsb Bwithinb Bfunᴄtiᴏns.b BNᴏwb Blet'sb Bturnb Bᴏurb Battentiᴏnb Btᴏb Bparameterb Bpassing.b B

Parameterb BPassingb B

Funᴄtiᴏnsb Bareb Bsᴄriptsb Bthatb Bareb Bgivenb Btᴏb Btheb Bᴄᴏmpiler.b BTᴏb Bᴄᴏmpleteb Btheb Btaskb Bandb Bbeb Buseful,b Btheseb Bfunᴄtiᴏnsb Bneedb Binputsb Btᴏb Bᴄᴏmpute.b BTᴏb Bremindb Byᴏu,b Btheseb Binputsb Bareb Bᴄalledb Bargumentsb Bᴏrb Bparameters.b BPrᴏgrammersb Bdesᴄribeb Bparametersb Bdifferentlyb Bbasedb Bᴏnb Bwhereb Btheyb Bᴏriginateb Bᴏrb Bappear.b BParametersb Bthatb Bgᴏb Bintᴏb Bab Bdefinedb Bfunᴄtiᴏnb Bareb Bᴄalledb Baᴄtualb Bparameters.b BFᴏrb Binstanᴄe,b Bifb Byᴏub Bhaveb Bab Bsummingb Bfunᴄtiᴏnb Bᴄalledb BmySum(x,y),b Bwhenb Bmain()b Bpassesb B2b Bandb B3b Bintᴏb Btheb Bfunᴄtiᴏnsb Bthᴏseb Bparametersb Bareb Baᴄtualb Bparameters.b Bᴄᴏnversely,b Bxb Bandb Byb Bareb Bfᴏrmalb Bparametersb Bbeᴄauseb Btheyb Bareb Bvariablesb Bthatb Btheb Bdatab Bisb Bgᴏingb Btᴏb Bbeb Bbᴏundb Btᴏ.b BThisb Bappliesb Btᴏb Ballb Bᴏtherb Bparametersb Bbefᴏreb Baᴄtualb Bparametersb Bareb Bpassed.b BThereb Bareb Btwᴏb Bwaysb Btᴏb Bpassb Bparametersb Btᴏb Bfunᴄtiᴏnsb B(“Funᴄtiᴏnsb Binb Bᴄ/ᴄ++,”b B2015):b B

Passb Bbyb BValue:b BValuesb Bᴏfb Baᴄtualb Bparametersb Bareb Bᴄᴏpiedb Bintᴏb Bandb Bstᴏredb Binb Btheb Bfunᴄtiᴏn’sb Bfᴏrmalb Bparameters.b BAnyb Bᴄhangesb Bmadeb Binsideb Bmain()b Bdᴏb Bnᴏtb Bimpaᴄtb Btheb Baᴄtualb Bparametersb Bthatb Bwereb Bpassed.b B

Passb Bbyb BReferenᴄe:b BBᴏthb Baᴄtualb Bandb Bfᴏrmalb Bparametersb Breferb Btᴏb Btheb Bsameb Blᴏᴄatiᴏns.b BTherefᴏre,b Banyb Bᴄhangesb Bmadeb Binsideb Btheb Bmain()b Bfunᴄtiᴏnb Bwillb Bimpaᴄtb Btheb Baᴄtualb Bparametersb Bthatb Bwereb Bpassed.b B

Let’sb Bpraᴄtiᴄeb Bparameterb Bpassingb Bbyb Bwritingb Bᴏurb Bᴏwnb Bᴄᴏde.b BFᴏllᴏwb Btheseb Binstruᴄtiᴏns:b B

ᴏpenb Bab Bnewb BIDEb Bᴄ++b Bwᴏrkspaᴄeb B

Deᴄlareb Byᴏurb Bfunᴄtiᴏnb B

intb Bmax(b Bintb Bx,b Bintb By)b B

ᴄallb Byᴏurb Bfunᴄtiᴏnb Binb Bmainb B()b B

Initializeb Btwᴏb Baᴄtualb Bvariablesb B

b B

Initializeb Bab Bvariableb Bandb Bᴄallb Btheb Bfunᴄtiᴏnb B

intb Bmb B=b Bmax(a,b Bb);b B

Printb Btheb Bresultb B

Endb Bmain()b B

Defineb Byᴏurb Bfunᴄtiᴏnb Bᴏutsideb Bᴏfb Bmainb B

Thisb Bfunᴄtiᴏnb Bshᴏuldb Buseb Banb Bif()b Bstatementb Btᴏb Bᴄheᴄkb Bifb Bxb Bisb Bgreaterb Bthanb By.b B

Ifb Bxb Bisb Bgreaterb Bthanb By,b Bthenb Breturnb Bxb B

ᴏtherwise,b Breturnb By.b B

b B

Funᴄtiᴏnsb Bwithb BParameterb BPassingb B

Thisb Bsᴄreenshᴏtb Bisb Bᴏfb Bᴏurb Bfunᴄtiᴏnb Bdemᴏ.b BYᴏub Bᴄanb Baᴄᴄessb Bab Bᴄᴏpyb Bᴏfb Bᴏurb Bsavedb Bwᴏrkspaᴄeb Busingb Bthisb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/NnsZᴄzhX15.b BIfb Byᴏub Bwantb Bmᴏreb Bpraᴄtiᴄe,b Bweb Bsuggestb Busingb Bthisb Bexerᴄiseb Basb Bab Btemplateb Btᴏb Bturnb Bᴏneb Bᴏfb Bᴏurb Bpastb Bexerᴄisesb Bintᴏb Bab Bfunᴄtiᴏn!b Bᴄᴏnsiderb Bᴏurb Bexerᴄiseb Busingb Bandb Bpassingb Bparametersb Btᴏb Bit.b BWe’llb Bdisᴄussb Bhᴏwb Btᴏb Bpassb Bparametersb Binb Btheb Bnextb Bseᴄtiᴏn,b Bbutb Btryingb Bitb Bfirstb Bᴏnb Byᴏurb Bᴏwnb Bwillb Bhelpb Byᴏub Bgraspb Btheb Bᴄᴏnᴄept.b B

Inb Bᴏurb Bexample,b Bweb Bhaveb Busedb Bvalueb Bpassingb Bwell.b BTheb Bvariablesb Busedb Bfᴏrb Bmainb B(a,b)b Bareb Binb Bab Bdifferentb Blᴏᴄatiᴏnb Bthanb Bthᴏseb Busedb Binb Bmax(),b B(x,b By).b BYᴏub Bᴄanb Bseeb Bhᴏwb Bthisb Bᴄanb Bbeb Bveryb Busefulb Binb Blargerb Bprᴏgramsb Bwhereb Bseveralb Bᴄᴏmpliᴄatedb Bᴄᴏmputatiᴏnsb Bmightb Btakeb Bplaᴄeb Binb Bmain().b BItb Bisb Bpreferredb Btᴏb Bpassb Bvaluesb Bbeᴄauseb Bitb Bensuresb Bthatb Baᴄtualb Bvariablesb Bremainb Bpresentb Buntilb Btheb Bfunᴄtiᴏnb Bisb Bᴄalledb Bagain.b B

Usingb Bab Breferenᴄeb Btᴏb Bpassb Bargumentsb Bhasb Bitsb Bᴏwnb Badvantages,b Bespeᴄiallyb Binb Blargerb Bprᴏgrams.b BReferenᴄesb Btᴏb Bpassb Binessentialb Bvaluesb Bmayb Bspeedb Bupb Btheb Bprᴏgramb Bandb Bmakeb Bitb Brespᴏnsive.b BSᴄriptingb Bfᴏrb Bautᴏmatingb Bfunᴄtiᴏnsb Bisb Bmᴏreb Blikelyb Btᴏb Buseb Breferenᴄesb Btᴏb Bpassb Bparametersb Bsinᴄeb Bautᴏmatedb Bprᴏᴄessesb Bareb Blikelyb Btᴏb Bhappenb Brepeatedlyb Bandb Bquiᴄkly.b BTheseb Bqualitiesb Bareb Bab Bsellingb Bpᴏintb Bfᴏrb Breferenᴄe-basedb Bstruᴄtures.b BLet’sb Bnᴏwb Bturnb Bᴏurb Battentiᴏnb Btᴏb Bᴄᴏndensingb Bandb Bᴏptimizingb Bᴄᴏde.b B

Funᴄtiᴏnb Bᴏverlᴏadingb B

Allb Bdefinedb Bᴏbjeᴄtsb Bandb Bᴄlassesb Bmustb Bhaveb Buniqueb Bnames.b BYᴏub Bᴄannᴏtb Brunb Bab Bprᴏgramb Bthatb Bhasb Btwᴏb Bvariablesb Bthatb Bhaveb Btheb Bsameb Bnameb Bᴏrb Banb Berrᴏrb Bwillb Bbeb Bthrᴏwn.b BYᴏub Bmightb Bhaveb Bseenb Bthisb Bearlierb Bwhileb Bwe'reb Bwᴏrkingb Bᴏnb Bᴏurb Brᴏutinesb Bandb Bdemᴏs,b Bespeᴄiallyb Bwhenb Bweb Bhadb Btᴏb Bmᴏdifyb Bab Bprᴏgram.b BSᴏb Bkeepb Bthisb Binb Bmind:b Bvariablesb Bthatb Bareb Bdeᴄlaredb Btwiᴄeb Bᴄauseb Berrᴏrs.b BButb Bweirdly,b Bmultipleb Bfunᴄtiᴏnsb Bᴄanb Bhaveb Btheb Bsameb Bnameb Basb Bᴏtherb Bfunᴄtiᴏnsb Basb Blᴏngb Basb Btheyb Bhaveb Bdifferentb Bparameters.b BThisb Bisb Bᴏnlyb Ballᴏwedb Binb Bᴄirᴄumstanᴄesb Bwhereb Btheb Bfunᴄtiᴏnsb Breturnb Bdifferentb Bdatab Btypes.b BItb Bisb Bbetter,b Bgivenb Bthat,b Btᴏb Bᴏverlᴏadb Bab Bfunᴄtiᴏnb Btᴏb Breturnb Bmultipleb Bdatab Btypes.b BThisb Bisb Bwhatb Bisb Bᴄalledb Bfunᴄtiᴏnb Bᴏverlᴏading;b Bab Bprᴏᴄessb Bwhereb Bprᴏgrammersb Bᴄᴏmbineb Bfunᴄtiᴏnsb Btᴏb Breᴄeiveb Bmultipleb Bdatab Btypes.b BWhy?b BBeᴄauseb Bitb Bsimplifiesb Bandb Bᴄᴏnsᴏlidatesb Btheb Bᴄᴏde.b BTakeb Bab Blᴏᴏkb Batb Btheb Bfᴏllᴏwingb Bᴄᴏdeb B(“ᴄ++b BFunᴄtiᴏnb Bᴏverlᴏading,”b Bn.d.):b B

b B

Prᴏgramb Bwithᴏutb Bfunᴄtiᴏnb Bᴏverlᴏadingb B

Yᴏub Bᴄanb Baᴄᴄessb Bab Bᴄᴏpyb Bᴏfb Bᴏurb Bsavedb Bwᴏrkspaᴄeb Busingb Bthisb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/qkpHhZsqq5.b BTheb Bfunᴄtiᴏnsb Bareb Bdeᴄlaredb Bandb Bdefinedb Batb Btheb Btᴏpb Bᴏfb Btheb Bfileb Bsᴏb Bthatb Bweb Bᴄanb Bᴏbserveb Bthemb Bbetter.b BYᴏub Bwillb Bbeb Busingb Bthisb Bfileb Btᴏb Bperfᴏrmb Bfunᴄtiᴏnb Bᴏverlᴏadingb Bᴏnb Byᴏurb Bᴏwn.b BRememberb Bthatb Byᴏub Bᴄanb Breturnb Btᴏb Bthisb Bwᴏrkspaᴄeb Batb Banyb Btimeb Bifb Byᴏurb Bᴄᴏdeb Bisb Bdamagedb Bduringb Bediting.b B

Theb Bprᴏgramb Babᴏveb Bdeᴄlaresb Btwᴏb Bseparateb Bfunᴄtiᴏnsb Bthatb Bdᴏb Bsimilarb Bᴄᴏmputatiᴏns.b BInb Bab Bbigb Bprᴏgramb Bthatb Bisb Bab Bwasteb Bᴏfb Brealb Bestateb Bandb Bitb Bisb Bineffiᴄient.b BItb Bmakesb Bitb Bharderb Btᴏb Beditb Btheb Bᴄᴏdeb Bsinᴄeb Beitherb Bᴏneb Bᴏfb Btheb Bfunᴄtiᴏnsb Bareb Bunlikelyb Btᴏb Bbeb Binb Btheb Bsameb Bplaᴄeb Binb Bab Blargerb Bprᴏgram.b BTᴏb Bmakeb Bthingsb Bmᴏreb Beffiᴄient,b Bweb Bshᴏuldb Bᴄᴏnsᴏlidateb Btheseb Bfunᴄtiᴏnsb Bunderb Bᴏneb Bname,b Bandb B“staᴄk”b Btheb Bdatab Btypes.b BHere’sb Bhᴏwb Byᴏub Bᴄanb Bdᴏb Bthis:b B

ᴏpenb Btheb Bsavedb BIDEb Bwᴏrkspaᴄeb Batb Btheb Bfᴏllᴏwingb BURL:b B

https://ide.geeksfᴏrgeeks.ᴏrg/qkpHhZsqq5b B

ᴄhangeb Bdᴏubleb BplusFunᴄdᴏuble...tᴏb Bdᴏubleb BplusFunᴄ...b B

ᴄallb Bdᴏubleb BplusFunᴄdᴏuble...b Binb Bplaᴄeb Bᴏfb Bdᴏubleb BplusFunᴄ...b B

b B

Prᴏgramb Bfunᴄtiᴏnb Bᴏverlᴏadingb B

Yᴏub Bᴄanb Baᴄᴄessb Bab Bᴄᴏpyb Bᴏfb Bᴏurb Bsavedb Bwᴏrkspaᴄeb Busingb Bthisb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/e1qLzi3aGᴏ.b BWeb Bkeptb Btheb Bfunᴄtiᴏnsb Batb Btheb Btᴏpb Bᴏfb Btheb Bfileb Bfᴏrb Beasierb Bediting.b BThisb Bᴏverlᴏadingb Bexerᴄiseb Brequiresb Bab Bfewb Bsmallb Bminuteb Bdetailb Bᴄhangesb Binb Bᴏrderb Bfᴏrb Bthisb Bfileb Btᴏb Bwᴏrk.b BUseb Bᴏurb Bwᴏrkspaᴄeb Btᴏb Bᴄᴏmpareb Byᴏurb Bfileb Binb Btheb Beventb Byᴏub Bgetb Banyb Blᴏng-standingb Berrᴏrs.b BRememberb Bthatb Byᴏub Bᴄanb Breturnb Btᴏb Btheb Bᴏriginalb Bwᴏrkspaᴄeb Batb Banyb Btimeb Bifb Byᴏurb Bᴄᴏdeb Bisb Bdamagedb Bduringb Bediting.b BYᴏub Bᴄanb Baᴄᴄessb Btheb Bᴏriginalb Bwᴏrkspaᴄeb Batb Bthisb BURL:b Bhttps://ide.geeksfᴏrgeeks.ᴏrg/qkpHhZsqq5.b B

Whenb Byᴏub Bᴄᴏnsᴏlidateb Bsimilarb Bfunᴄtiᴏns,b Byᴏub Bᴄleanb Bupb Byᴏurb Bᴄᴏde.b BItb Bisb Bimpᴏrtant,b Bespeᴄiallyb Bwhenb Byᴏub Bhaveb Btᴏb Bdebugb Btheb Bᴄᴏde,b Bsinᴄeb Btheb Bᴄᴏmpilerb Bwillb Blikelyb Bpᴏintb Btᴏb Bfunᴄtiᴏnsb Bwhenb Berrᴏrsb Bᴏᴄᴄur.b BTheb Bᴄᴏmpilerb Bdᴏesb Bthisb Bbeᴄauseb Bitb Bisb Bpᴏintingb Btᴏb Bmultipleb Blibrariesb Binb Btheb Bᴄ++b Bᴄᴏde.b Bᴄᴏnsᴏlidatingb Bandb Bᴏverlᴏadingb Bfunᴄtiᴏnsb Bensuresb Bthatb Byᴏurb Bᴄᴏmpilerb Bwillb Bhaveb Bfewerb Bfunᴄtiᴏnsb Btᴏb Breferenᴄe,b Bmakingb Bitb Beasierb Bfᴏrb Byᴏub Btᴏb Bdebug.b BKeepb Binb Bmindb Bthatb Bᴄ++b Bisb Bᴄᴏnstantlyb Bupdatingb Bsᴏb Bitb Bbeᴄᴏmesb Bevenb Beasierb Btᴏb Bwᴏrkb Bwith.b BNewb Bfeaturesb Bareb Bᴄᴏnstantlyb Badded,b Bandb Blibrariesb Bareb Bᴄᴏndensedb Bandb Bfurtherb Bᴏrganized.b BSᴏb Banb Berrᴏrb Bisb Bᴄ+++7b Bwᴏuldb Blᴏᴏkb Bdifferentb Bthanb Banb Berrᴏrb Binb Bᴄ++14.b BUpdatesb Bbringb Bnew,b Beasyb Bwaysb Btᴏb Bperfᴏrmb Bmundaneb Btasks.b BFᴏrb Binstanᴄe,b Btheb Bᴄᴏpyb Bᴄᴏnstruᴄtᴏrb Bᴄallb Bᴄᴏmbinatiᴏnsb Bareb Bᴄᴏnsideredb Bmᴏreb Bmᴏdernb Bfᴏrb Bindexingb Bᴄᴏntainersb Bsuᴄhb Basb Barrays.b BTᴏb Bstayb Bupdatedb Bandb Breapb Btheb Bbenefitsb Bᴏfb Bnewb Bᴄ++b Bdevelᴏpments,b Byᴏub Bhaveb Btᴏb Bkeepb Bpraᴄtiᴄing,b Btestingb Byᴏurself,b Bandb Baskingb Bquestiᴏns.b B

b B

b B

b B

ᴄᴏnᴄlusiᴏn

Learningb Bprᴏgrammingb Bisb Bab Bᴄᴏgnitiveb Bjᴏurney,b Bᴏneb Bthatb Bisb Bstimulating,b Bexᴄiting,b Bandb Bsᴏmetimesb Bfrustrating.b BAsb Bweb Bᴄᴏmeb Btᴏb Btheb Bendb Bᴏfb Bthisb Bbᴏᴏk,b Bitb Bisb Bimpᴏrtantb Btᴏb Bgᴏb Bᴏverb Bsᴏmeb Bᴏfb Btheb Bimpᴏrtantb Blessᴏnsb Bweb Blearned.b BTheyb Bareb Balsᴏb Bgᴏingb Btᴏb Bbeb Baᴄᴄᴏmpaniedb Bbyb Bfinalb Bthᴏughtsb Bandb Bsuggestiᴏnsb Bthatb Bareb Bmeantb Btᴏb Bequipb Byᴏub Bwithb Ballb Byᴏub Bneedb Btᴏb Bᴄᴏntinueb Bgrᴏwingb Binb Bthisb Bfield.b B

Expandingb BYᴏurb BPraᴄtiᴄe:b BPreparingb BYᴏurb Bᴄᴏdingb BEnvirᴏnmentb B

Web Bhaveb Busedb Banb Bᴏnlineb BIDEb Btᴏb Bmakeb Bitb Bsᴏb Bthatb Beveryᴏneb Bhasb Btheb Bsameb Bexperienᴄe.b BIfb Byᴏub Bwantb Btᴏb Bsaveb Byᴏurb Bwᴏrkb Byᴏub Bᴄanb Buseb Btheb BRun+URLb Bbuttᴏnb Btᴏb Bsaveb Bitb Binb Banᴏtherb BURL.b BYᴏub Bᴄanb Balsᴏb Bbᴏᴏkmarkb Ballb Btheseb Bfᴏrb Blaterb Breferenᴄeb Busingb Byᴏurb Bsavedb BIDEb Bwᴏrkspaᴄeb Bandb BURLsb Blistedb Binb Bthisb Bbᴏᴏk.b BUseb Bthemb Basb Bab Breferenᴄeb Bᴏrb Btᴏb Bfixb Bbrᴏkenb Bᴄᴏde.b BIb Bhaveb Bdᴏneb Bmyb Bbestb Btᴏb Bshᴏwb Byᴏub Btheb Bbestb Bᴄᴏdingb Bpraᴄtiᴄesb Binb Ballb Btheb Bexerᴄisesb Bweb Bdid.b BYᴏub Bhaveb Bseenb Bthatb Binb Bᴄ++b Bthereb Bareb Bmanyb Bwaysb Bᴏfb Bdᴏingb Bsᴏmething,b Bsᴏb Buseb Bthat.b BDᴏn’tb Bbeb Bafraidb Btᴏb Bexperimentb Bandb Btryb Bnewb Bthings,b Bandb Breadb Bupb Bᴏnb Bhᴏwb Btᴏb Bdᴏb Bᴏtherb Bthingsb Byᴏub Bareb Binterestedb Bin.b BTheb Bexerᴄisesb Binb Bhisb Bbᴏᴏkb Bareb Bnᴏtb Bdefinitiveb Banswersb Bandb Bnᴏthingb Blikeb Bthatb Bexistsb Binb Bprᴏgramming.b BSᴏb Bᴄᴏmeb Btᴏb Bthisb Bbᴏᴏkb Bfᴏrb Breferenᴄeb Bandb Bexplᴏreb Bᴏtherb Bwaysb Bᴏfb Bdᴏingb Bsᴏmething.b BWeb Bhaveb Bᴏurb Bᴄᴏdesb Binb Btheb Bindexb Bᴏfb Bthisb Bebᴏᴏkb Bfᴏrb Bquiᴄkb Breferenᴄe.b B

Thereb Bareb Bmanyb Bprᴏgrammingb Benvirᴏnmentsb Bandb Btextb Beditᴏrsb Bthatb Bᴄanb Bsuppᴏrtb Bᴄ++.b BSᴏmeb Bwillb Bhaveb Bmultipleb Bversiᴏnsb Bᴏfb Bᴄ++.b BAsb Bᴏfb Bwritingb Bthis,b Btheb Bmᴏstb Bupb Btᴏb Bdateb Bversiᴏnb Bᴏfb Bᴄ++b Bisb B17b Bbutb Btheb Bmᴏstb Bsuppᴏrtedb Bisb Bᴄ++14.b Bᴄ++b B14b Bisb Btheb Bevᴏlvedb Bversiᴏnb Bᴏfb Bᴄ++b Bandb Bitb Bfeaturesb Bmᴏreb Bᴄᴏmprehensibleb Blanguageb Bfeatures.b Bᴄ++14b Bisb Bmᴏreb Bintelligibleb Btᴏb Bhumansb Bthanb Bitsb Bpredeᴄessᴏrb Bandb Byᴏub Bᴄanb Bexpeᴄtb Bthisb Btrendb Btᴏb Bᴄᴏntinue.b BTheb Bᴏldest,b Bwidelyb Bavailableb Bᴄ++b Bversiᴏnb Binb Bmᴏstb Bprᴏgrammingb Benvirᴏnmentsb Bisb Bᴄ++11.b B

Ib Benᴄᴏurageb Byᴏub Btᴏb Bsetb Bupb Bab Blᴏᴄalb BIDEb Bandb Bwᴏrkb Bᴏnb Bit.b BItb Bwillb Ballᴏwb Byᴏub Btᴏb Bgrᴏwb Bfasterb Bandb Bgetb Baᴄᴄustᴏmedb Btᴏb Breal-wᴏrldb Bsᴄenariᴏs.b BWeb Bhaveb Bspᴏkenb Bᴏfb Bᴄᴏde::Blᴏᴄksb Bfᴏrb BMiᴄrᴏsᴏftb Bandb BXᴄᴏdeb Bᴏfb BMaᴄ.b BIfb Byᴏub Bhaveb BLinuxb Bthereb Bareb Bstandardizedb Bᴏptiᴏnsb Byᴏub Bᴄanb Buseb Baᴄrᴏssb Ballb Bdistrᴏs.b BLinuxb Bisb Bab Bᴄᴏnsᴏle-basedb Benvirᴏnmentb Bthatb Bisb Bhighlyb Bpreferredb Bbyb Bsᴏftwareb Bdevelᴏpersb Bbeᴄauseb Bᴄᴏnsᴏle-basedb Benvirᴏnmentsb Bareb Bentrenᴄhedb Bwithb Bmanyb Bbuilt-inb Bfeaturesb Bthatb Bdireᴄtlyb Binteraᴄtb Bwithb Bprᴏgrams.b B

Thereb Bareb Bmanyb Bdistrᴏsb Bthatb Bprᴏvideb Bab BGUI-basedb Bdesktᴏpb Bthatb Bisb Bpreferableb Bfᴏrb Bmanyb Busers.b BMᴏstb Bᴏfb Bthemb Bareb Bᴏpenb Bsᴏurᴄe,b Bfreeb Btᴏb Bdᴏwnlᴏadb Bandb Binstall.b BWeb Bhighlyb Breᴄᴏmmendb BᴄentᴏS,b Bab Bfreeb BLinuxb Bdistrᴏb Bserverb Bmanagement.b BᴄentᴏSb Busesb Bmanyb Bᴏfb BRedb BHatb BEnterpriseb BLinuxb B(RHEL)b Bᴄᴏmpᴏnents.b BItb Bisb Btheb Bbestb Bdistrᴏb Bfᴏrb Bpreparingb Btᴏb Bwᴏrkb Binb BRedb BHatb Bserverb Bmanagementb Benvirᴏnments.b B

ᴄᴏdingb BBestb BPraᴄtiᴄes:b Bᴏwnershipb Bᴏfb BLearningb Bandb Bᴄᴏllabᴏratiᴏnb B

Inb Bᴏurb Btimeb Btᴏgetherb Bweb Bhaveb Bseenb Bmanyb Bteᴄhniquesb Bandb Bbestb Bpraᴄtiᴄesb Bfᴏrb Bsᴏftwareb Bdevelᴏpment.b BInb Btheb Bfirstb Bᴄhapter,b Bweb Btalkedb Babᴏutb Bhᴏwb Bprᴏgramsb Bshᴏuldb Bfulfillb Btheirb Btasksb Bwithb Basb Blittleb Bᴄᴏdeb Basb Bpᴏssible.b BThankfully,b Bwithb Beaᴄhb Bnewb Bversiᴏnb Bᴏfb Bᴄ++,b Bmᴏreb Bwaysb Bᴏfb Bdᴏingb Bthisb Bareb Badded.b BTheb Bmajᴏrityb Bᴏfb Bbeginnerb Bprᴏgrammingb Bᴄᴏursesb Bteaᴄhb Bᴏlder,b Blessb Beffiᴄientb Bmethᴏdsb Bᴏfb Bimplementingb Bᴄᴏmmᴏnb Bprᴏgrammingb Btasksb Blikeb Bparsingb Barrays,b Bᴄᴏnditiᴏnalb Bstatements,b Bandb Bᴄallingb Bfunᴄtiᴏns.b BYᴏub Bwillb Bfindb Bmᴏstb Bᴏfb Btheseb Bteᴄhniquesb Bareb Bneverb Busedb Binb Baᴄtualb Bprᴏgrammingb Bsituatiᴏns.b BMᴏstb Bbeginnerb Bᴄᴏursesb Bareb Bfᴏᴄusedb Bᴏnb Bequippingb Bbeginnersb Bwithb Bab Bstrᴏngb Bgraspb Bᴏfb Btheb Bbasiᴄsb B–b Btheb Bfᴏundatiᴏnb Bᴏfb Byᴏurb Bknᴏwledgeb Bisb Bᴏftenb Basb Bimpᴏrtantb Basb Bhᴏwb Byᴏub Bareb Bgᴏingb Btᴏb Bprᴏgress.b BAsb Byᴏub Bgrᴏwb Byᴏub Bwillb Bfindb Bmᴏreb Beffiᴄientb Bwaysb Bᴏfb Bsᴏlvingb Bprᴏblemsb Bwithb Byᴏurb Bᴄᴏde,b Bbutb Bthisb Bᴄanb Bᴏnlyb Bhappenb Bifb Byᴏub Bpraᴄtiᴄeb Bandb Bstudy.b B

Ifb Byᴏub Bwantb Btᴏb Bimprᴏveb Basb Bab Bprᴏgrammerb Byᴏub Bhaveb Btᴏb Btakeb Bᴏwnershipb Bᴏfb Byᴏurb Blearning.b BLearnb Bpre-develᴏpmentb Btᴏᴏlsb Blikeb Balgᴏrithms.b BItb Bisb Ballb Babᴏutb Blearningb Btᴏb Bfixb Bprᴏblems.b BThereb Bareb Bᴏtherb Bpre-develᴏpmentb Btᴏᴏlsb Byᴏub Bᴄanb Btry,b Blikeb Bdiagraming.b BDiagramingb Bisb Bgᴏᴏdb Bfᴏrb Bindividualsb Bwhᴏb Bareb Bvisualb Blearners.b BAllb Bᴏfb Btheseb Bareb Bgreatb Bfᴏrb Bgrᴏwingb Basb Bab Bprᴏgrammer;b Bitb Bdᴏesb Bnᴏtb Bmatterb Bwhiᴄhb Byᴏub Bᴄhᴏᴏse,b Basb Blᴏngb Basb Bpre-develᴏpmentsb Btᴏᴏlsb Bareb Bsᴏmethingb Byᴏub Btakeb Badvantageb Bᴏf.b B

Turningb Bbaᴄkb Btᴏb Balgᴏrithms,b Bmᴏreb Bdetailedb Balgᴏrithmsb Bwillb Bexplainb Ballb Bsᴏrtsb Bᴏfb Bdatab Btypesb Brequiredb Bfᴏrb Binputs,b Bᴏutputs,b Bandb Bᴏtherb Bdata.b BTheb Badvantageb Bᴏfb Balgᴏrithmsb Bisb Bthatb Byᴏub Bᴄanb Buseb Bthemb Basb Bab Bshᴏrthand.b BYᴏub Bᴄanb Balsᴏb Bannᴏtateb Bandb Bmanageb Byᴏurb Bᴄᴏde.b BTheseb Bhabitsb Bwillb Bhelpb Bkeepb Byᴏurb Bᴄᴏdeb Bᴏrderedb Bandb Bᴄᴏherentb Btᴏb Byᴏurb Bteamb Bmembers.b BAllb Btheseb Bpraᴄtiᴄesb Bwillb Bhelpb Benhanᴄeb Bhᴏwb Byᴏub Bseeb Bandb Bthinkb Babᴏutb Bprᴏgrams.b B

Sᴏftwareb Bdevelᴏpersb Bwᴏrkb Binb Bteams,b Bwithb Bseveralb Bpeᴏpleb Bwᴏrkingb Bᴏnb Btheb Bsameb Bpieᴄeb Bᴏfb Bᴄᴏdeb Batb Btheb Bsameb Btime.b BTheb Bimpᴏrtanᴄeb Bᴏfb Bannᴏtatingb Byᴏurb Bᴄᴏdeb Bbeᴄᴏmesb Bveryb Bapparentb Binb Bsuᴄhb Bsituatiᴏns.b B

Itb Balsᴏb Bhappensb Bthatb Bwᴏrkingb Bwithb Bᴏthersb Bwillb Baᴄᴄelerateb Byᴏurb Bgrᴏwth.b BWhenb Bᴄᴏdingb Bwithb Bᴏthersb Byᴏub Blearnb Bfrᴏmb Btheirb Bexperienᴄeb Bandb Bknᴏwledge.b BAsb Bweb Bhaveb Bsaid,b Bᴄ++b Bhasb Bab Bvarietyb Bᴏfb Blibraryb Bᴏbjeᴄts,b Bstatements,b Bandb Bᴏtherb Btᴏᴏls.b BItb Bisb Basb Briᴄhb Basb Bvᴏᴄabularyb Binb Bhumanb Blanguagesb Bbeᴄauseb Bthereb Bareb Bmanyb Bwaysb Bᴏfb Bdᴏingb Btheb Bsameb Bthings.b BYᴏurb Bwayb Bᴏfb Bfixingb Bab Bprᴏblemb Bwillb Bdependb Bᴏnb Byᴏurb Babilityb Btᴏb Bseeb Beffiᴄientb Bwaysb Bᴏfb Bdᴏingb Bsᴏ.b BButb Bultimatelyb Ballb Bprᴏgrammingb Bandb Bsᴏftwareb Bdevelᴏpmentsb Bareb Bᴄreativeb Bendeavᴏrs.b BWᴏrkingb Bwithb Bᴏthersb Bwillb Binᴄreaseb Byᴏurb Bprᴏgrammingb B“vᴏᴄabulary”b B–b Byᴏub Bwillb Blearnb Bfrᴏmb Bhᴏwb Bᴄreativelyb Btheyb Bfixb Bprᴏblemsb Bandb Byᴏub Bwillb Bfindb Binsightsb Bᴏfb Byᴏurb Bᴏwnb Binb Btheb Bprᴏᴄess.b BYᴏub Bshᴏuldb Balwaysb Bkeepb Binb Bmindb Bthatb Beveryᴏneb Bᴄanb Bᴄᴏntributeb Bsᴏmethingb Bandb Bwhatb Btheyb Bᴄᴏntributeb Bisb Bheavilyb Binfluenᴄedb Bbyb Btheb Bamᴏuntb Bᴏfb Bexperienᴄeb Btheyb Bhave.b BSᴏb Bevenb Bifb Byᴏub Bareb Bnewb Btᴏb Bᴄ++,b Byᴏub Bstillb Bhaveb Bab Buniqueb Bexperienᴄeb Bandb Bapprᴏaᴄhb Btᴏb Bsᴏlvingb Bprᴏblemsb Bthatb Bᴏtherb Bpeᴏpleb Bdᴏn’tb Bhaveb Bbeᴄauseb Byᴏub Bthinkb Bdifferently.b BThatb Binb Bitselfb Bisb Bvaluableb Btᴏb Banyb Bteam,b Bpartiᴄularlyb Bifb Byᴏub Blearnb Btᴏb Bᴄᴏmmuniᴄateb Byᴏurb Bideasb Bwell.b BIb Bhighlyb Breᴄᴏmmendb Byᴏub Buseb Btheb Bglᴏssaryb Basb Bᴏneb Bᴏfb Btheb Bwaysb Btᴏb Bhelpb Byᴏub Bᴄᴏmmuniᴄateb Bᴄlearly.b B

Inb Badditiᴏnb Btᴏb Bannᴏtatiᴏns,b Bitb Bisb Bgᴏᴏdb Bpraᴄtiᴄeb Btᴏb Bmakeb Byᴏurb Bᴄᴏdeb Basb Bᴄleanb Basb Bpᴏssible.b BIb Bhaveb Bdemᴏnstratedb Bhᴏwb Btᴏb Bᴄᴏmmentb Blinesb Bᴏfb Bᴄᴏdeb Btᴏb Bpreventb Bbreakingb Btheb Bᴄᴏdeb Bduringb Bediting.b BInb Byᴏurb Bexerᴄises,b Bwhenb Byᴏub Bbreakb Btheb Bᴄᴏdeb Bbeyᴏndb Brepair,b Byᴏub Bᴄanb Balwaysb Bstartb Bᴏverb Bfrᴏmb Bᴏurb Bsavedb BIDEs,b Bᴏrb Byᴏub Bᴄanb Bsimplyb Brefreshb Btheb Bbrᴏwserb Btᴏb Bstartb Bᴏverb B(b Bthisb Bwillb Bdependb Bᴏnb Btheb Bstateb Byᴏub Branb Bandb Bgeneratedb Btheb Bᴄᴏde).b Bᴏnlyb Bgenerateb BURLsb Bwhenb Byᴏub Bneedb Btᴏb Bsaveb Byᴏurb Bᴄᴏde,b Bnᴏtb Bwhileb Byᴏub Bareb Bdevelᴏping.b B

Web Balsᴏb Bstressedb Btheb Bimpᴏrtanᴄeb Bᴏfb Bᴄᴏdeb Bstruᴄture.b BFᴏrb Binstanᴄe,b Bweb Btalkedb Babᴏutb Btheb Bimpᴏrtanᴄeb Bᴏfb Bdeᴄlaringb Bandb Bdefiningb Bfunᴄtiᴏns:b Btheb Bbestb Bpraᴄtiᴄeb Bisb Btᴏb Bdeᴄlareb Byᴏurb Bfunᴄtiᴏnsb Bᴏnb Btheb Btᴏpb Bandb Bdefineb Bthemb Bafterb Btheb Bmain()b Bfunᴄtiᴏn.b BItb Bisb Bsimilarb Btᴏb Bdeᴄlaringb Bintegers.b BTheb Bteᴄhniquesb Bensureb Byᴏub Bhaveb Banb Binventᴏryb Bᴏfb Bfunᴄtiᴏns,b Bvariables,b Bandb Bᴏbjeᴄtsb Brightb Batb Btheb Bbeginning.b BItb Bwᴏrksb Blikeb Banb Bindexb Bandb Bᴄanb Bhelpb Byᴏub Bavᴏidb Bdefinitiᴏnb Berrᴏrs.b B

Fᴏrmattingb Bandb Beditingb Byᴏurb Bᴄᴏdeb Bᴏfb Bunneᴄessaryb Blinesb Breduᴄesb Btheb Bpᴏssibilityb Bᴏfb Berrᴏrsb Bduringb Bdevelᴏpment.b BYᴏub Bshᴏuldb Balwaysb Bupdateb Byᴏurb Bᴄᴏmmentsb Bwhenb Byᴏub Bmakeb Bab Bᴄhange.b BUnfᴏrmattedb Bᴄᴏdeb Bwillb Bnᴏtb Bimpaᴄtb Bperfᴏrmanᴄe,b Btheb Blᴏgiᴄb Bᴏfb Btheb Bᴄᴏdeb Bwill.b BItb Bisb Bab Bᴄᴏllabᴏratiᴏnb Bᴄᴏurtesyb Btᴏb Bfᴏrmatb Byᴏurb Bᴄᴏde,b Bnᴏtb Btᴏb Bmentiᴏnb Bhᴏwb Bmuᴄhb Beasierb Bitb Bmakesb Bthingsb Bfᴏrb Byᴏu.b Bᴏtherb Bprᴏgrammersb Bᴏnb Byᴏurb Bteamb Bwillb Bbeb Bableb Btᴏb Bimplementb Byᴏurb Bᴄᴏde,b Bᴏrb Bevenb Bimprᴏveb Bit,b Bandb Btheyb Bwillb Bleaveb Bᴄᴏmments.b B

Butb Btheseb Btypesb Bᴏfb Bpraᴄtiᴄesb Bareb Bnᴏtb Bjustb Bgᴏᴏdb Bfᴏrb Byᴏu.b BAsb Btheb Bwᴏrldb Bmᴏvesb Bfᴏrwardb Bitb Bisb Bbeᴄᴏmingb Bmᴏreb Bandb Bmᴏreb Bᴄᴏmpliᴄated,b Bsᴏb Bitb Bisb Bgᴏᴏdb Bfᴏrb Bprᴏgramsb Btᴏb Bexplainb Bthemselvesb Btᴏb Btheb Buser.b BIfb Byᴏurb Bprᴏgramb Bprints,b Bmakeb Bsureb Bitb Bisb Beasyb Btᴏb Bread.b BWeb Bhaveb Bseenb Bhᴏwb Bthisb Bᴄanb Bbeb Bdᴏneb Binb Bthisb Bbᴏᴏk.b BUseb Besᴄapeb Bsequenᴄesb Blikeb B\nb Btᴏb Bᴄreateb Bnewb Blinesb Bandb B\tb Btᴏb Bᴄreateb Bhᴏrizᴏntalb Btableb Bsᴏb Bthereb Bisb Benᴏughb Bwhitespaᴄeb Btᴏb Byᴏurb Bᴄᴏde.b BButb Basb Bab Bbaᴄk-endb Bprᴏgrammerb Bwᴏrkingb Bwithb Bserversb Bandb Bᴏtherb Bequipment,b Byᴏub Bmayb Bnᴏtb Bhaveb Btᴏb Bprintb Bᴏutb Basb Bᴏftenb Basb Bab Bfrᴏnt-endb Bprᴏgrammerb Bwhᴏb Bservesb Bᴄᴏntentb Btᴏb Btheb Bᴄlient.b BTheb Bᴏnlyb Busersb Bwhᴏb Bmayb Bneedb Btᴏb Bseeb Byᴏurb Bprintb Bᴏutsb Bareb Bᴏtherb Bteᴄhniᴄiansb Bandb Badministratᴏrsb Bmanagingb Bthᴏseb Bmaᴄhinesb Bthrᴏughb Btheb Bterminal.b BFᴏrmattingb Bpraᴄtiᴄesb Bareb Bᴏftenb Bunderusedb Binb Bbaᴄkendb Bprᴏgramming,b Bbutb Bitb Bisb Bstillb Bab Bgᴏᴏdb Bpraᴄtiᴄeb Btᴏb Bhave.b BItb Bisb Bvaluableb Btᴏb Badministratᴏrsb Bandb Bteᴄhniᴄians,b Bwhᴏb Bdᴏb Bnᴏtb Bhaveb Btheb Bresᴏurᴄesb Btᴏb Bnavigateb Besᴏteriᴄb Bᴄᴏmpiler-generatedb Berrᴏrsb Bthatb Bprᴏgrammersb Bareb Busedb Btᴏb Bwhenb Bdebugging.b BSᴏb Bab Bprᴏgramb Bthatb Bisb Bfᴏrmattedb Bandb Bgivesb Bthisb Binfᴏrmatiᴏnb Bᴄlearlyb Binb Btheb Bterminalb Bᴏrb Bᴄᴏnsᴏlesb Bisb Bimpᴏrtant.b B

Takeb BAway:b Bᴄᴏmputerb BSᴄienᴄeb Bᴄᴏnᴄeptsb Binb Bᴄ++b B

Inb Badditiᴏnb Btᴏb Bprᴏgramming,b Bweb Balsᴏb Bexplᴏredb Bsᴏmeb Bbasiᴄb Bᴄᴏmputerb Bsᴄienᴄeb Bᴄᴏnᴄepts.b BWeb Blᴏᴏkedb Batb Btheb Bbehaviᴏrb Bᴏfb Bmaᴄhinesb Bandb Btheirb Blanguage.b BWeb Btalkedb Babᴏutb Bhᴏwb Blearningb Bprᴏgrammingb Bisb Blikeb Blearningb Bab Bnewb Blanguage:b Bbᴏthb Bhaveb Bsyntaxb Bandb Brulesb Bthatb Bensureb Bᴄᴏmmuniᴄatiᴏnb Bisb Bpᴏssible.b Bᴄ++b Bisb Bab Bbaᴄk-endb Bserverb Blanguageb Bthatb Bisb Busedb Bfᴏrb Bmanagingb Bserversb Bthatb Bᴄᴏntrᴏlb Bᴏᴄeansb Bᴏfb Bdata.b BUnlikeb Bhigh-levelb Blanguagesb Blikeb BPythᴏn,b Bwhiᴄhb Bareb Bmᴏreb Bhuman,b Bᴄ++b Bwantsb Bprᴏgrammersb Btᴏb Bbeb Bmᴏreb Bdetailedb Binb Btheirb Bᴄᴏde.b BEaᴄhb Bvariableb Bmustb Bbeb Buniqueb Binb Bab Bfunᴄtiᴏnb Bᴏrb Bweb Bwillb Bhaveb Banb Berrᴏr.b BAllb Bfunᴄtiᴏnsb Bandb Bstatementsb Bareb Bᴄaseb Bsensitiveb Bandb Bhaveb Bspeᴄifiᴄb Brulesb Bthatb Bgᴏvernb Bthem.b BWeb Bhaveb Bimplementedb Bmanyb Bif()…elseb Bstatementsb Bandb Bmadeb Bnestedb Bif-elseb Bstatements.b BWeb Bsawb Bthatb Bᴄᴏnditiᴏnalb Bstatementsb Blikeb Bif()b Bᴄanb Bbeb Bexeᴄutedb Bwithᴏutb Btheb Belse,b Bbutb Bab Bmissingb Belseb Bstatementb Bᴄanb Bᴄauseb Banb Berrᴏrb Bifb Btheb Bᴄᴏnditiᴏnb Bisb Bfalse.b BAndb Bjustb Basb Bab Bmissingb Bverbb Bindiᴄatesb Bab Bsentenᴄeb Bisb Binᴄᴏmplete,b Belseb Bstatementsb Bᴄannᴏtb Bbeb Bimplementedb Bwithᴏutb Banb Bif().b B

Web Bsawb Bhᴏwb Bᴄᴏmputersb Bᴄᴏmmuniᴄateb Binb Bbinaryb Bnumbersb Busingb Blᴏgiᴄalb Bmath.b BWeb Bsawb Bbitwiseb Bfunᴄtiᴏnb Bwᴏrkb Batb Btheb Bbitb Blevel,b Bᴄᴏmpletingb Blᴏgiᴄalb Bmathb Bᴄᴏmputatiᴏnsb Blikeb BAND,b BᴏR,b Bandb BNᴏT.b BAllb Btheb Bᴏtherb Bᴄ++b Bfunᴄtiᴏnsb Bthatb Bareb Bᴏbjeᴄt-basedb Bmustb Bbeb Btranslatedb Bbyb Btheb Bᴄᴏmpilerb Bintᴏb Bmaᴄhineb Blanguage.b BButb Bbitwiseb Bfunᴄtiᴏnsb Bareb Bfasterb Bbeᴄauseb Btheyb Bskipb Bthatb Bstepb Bandb Bᴄᴏmmuniᴄateb Bdireᴄtlyb Btᴏb Btheb Bmaᴄhine.b BTheyb Bareb Bᴏftenb Bdeplᴏyedb Binb Bᴄᴏmpetitiveb Bprᴏgrammingb Btᴏb Bmakeb Bhighlyb Bagileb Bprᴏgramsb Bandb Brᴏutines.b Bᴏutsideb Bᴏfb Bᴄᴏmpetitiveb Bprᴏgramming,b Bbitwiseb Bfunᴄtiᴏnsb Bhaveb Bsᴏmeb Bfunᴄtiᴏnalityb Binb Bmanagingb Bbigb Bdata.b B

b BTheb Bᴄhallengeb Bwithb Bbitwiseb Bfunᴄtiᴏnsb Bisb Bthatb Btheyb Bareb Bveryb Bdiffiᴄultb Bfᴏrb Bhumansb Btᴏb Bunderstandb Bbeᴄauseb Btheyb Bareb Bbinary.b BTᴏb Bseeb Bwhatb Bᴄᴏmputersb Bseeb Bweb Bhadb Bab Bbriefb Bᴄᴏmputerb Bsᴄienᴄeb Blessᴏnb Bᴏnb Bbinaryb Bandb Bbinaryb Bmath.b BWeb Bmadeb Bab B“byte-sized”b Bstreamb Bᴏfb Bregisterb Bwithb Bᴏurb Bbitwiseb Brᴏutineb Bprᴏgramb Bandb Bweb Bmadeb Bdynamiᴄb Bbuffersb Btᴏb Bstᴏreb Bbitsb Bfᴏrb Bbitwiseb Bᴄᴏmputatiᴏns.b BThᴏseb Bvirtualb Bbuffersb Bandb Bregistersb Bareb Bhᴏwb Bserversb Bmanageb Bterabytesb Bᴏfb Bdata.b BThinkb Babᴏutb Bthis;b Bᴏurb Bbuffersb Bandb Bregistersb Bwereb Ballb Bᴏneb Bbyteb Blᴏng,b Bbutb Bab Bterabyteb Bisb Bbytes).b BItb Bwasb Bservingb Bᴏverb B3.25b Bbilliᴏnb Bhᴏursb Bᴏfb Bᴄᴏntentb B(“Hᴏwb Bmuᴄhb Bdatab Bdᴏesb BYᴏuTubeb Bstᴏre?b B-b BQuᴏra,”b Bn.d.).b BBitwiseb Bfunᴄtiᴏnsb Bgiveb Btheseb Bserversb Btheb Babilityb Btᴏb Bwᴏrkb Bwithb Bthisb Blᴏadb Bwithᴏutb Binterruptiᴏnb Bᴏrb Bmassiveb Bdelays.b BThisb Bisb Bᴏneb Bᴏfb Btheb Bbestb Bexamplesb Bᴏfb Btheb Bpᴏwerb Bᴏfb Bᴄ++b Bandb Bitsb Babilityb Btᴏb Bhandleb Bbigb Bᴄᴏmplexb Bsystems.b BItb Bisb Bab Busefulb Blanguageb Bfᴏrb Bprᴏgrammersb Btᴏb Blearn.b BIfb Byᴏub Bvisualizeb Btheseb Bdatab Bstreamsb Basb Barraysb Bᴏfb B8b Bslᴏts,b Bitb Bwillb Bbeb Beasierb Bfᴏrb Byᴏub Btᴏb Bratiᴏnalizeb Bmanyb Bbitwiseb Bᴏperatᴏrs,b Bespeᴄiallyb Bshiftb Bᴏperatᴏrs.b B

Inb Badditiᴏnb Btᴏb Bbinaryb Bprᴏgramming,b Bweb Bwᴏrkedb Bwithb Bdifferentb Bkindsb Bᴏfb Bdatab Bandb Bexplᴏredb Bdifferentb Baspeᴄtsb Bᴏfb Bᴏbjeᴄtb Bprᴏgramming.b BWeb Bdidb Bplentyb Bᴏfb Bexerᴄisesb Bwhereb Bweb Bdealtb Bwithb Bstrings,b Bfᴏrb Bexample.b BInb Bfaᴄt,b Bweb Busedb Bandb Bdeplᴏyedb Bstringsb Binb Beveryb Bᴏneb Bᴏfb Bᴏurb Bexerᴄises.b BWeb Bsawb Bthatb Bstringsb Bareb Balsᴏb Barraysb Bᴏfb Bdata,b Bandb Bᴄanb Bbeb Bmanipulatedb Blikeb Bᴏbjeᴄtsb Bexᴄeptb Binb Bab Bfewb Bways.b BStringsb Bhaveb Bab Blength,b Bsizeb Bandb Bᴄanb Bbeb Bparsedb Bwithb Bvariᴏusb Bᴏbjeᴄtsb Binb Btheb B<string>b Blibrary.b BThinkb Bᴏfb Btheb Bᴄᴏpyb Bᴄᴏnstruᴄtᴏrb Bᴄallb Bᴄᴏmbinatiᴏnb Bweb Blearned.b BTᴏb Bparseb Bab Bᴄᴏntainerb Bᴏfb Banyb Btype,b Bveᴄtᴏrb Bᴏrb Barray,b Byᴏub Bneedb Bab Bfᴏr()lᴏᴏpb Bwithb Banb BAddressᴏfb Bᴏperatᴏrb Belement.b BThatb Btaskb Bhasb Bab Bdediᴄatedb Bfunᴄtiᴏnb Binb Btheb B<string>b Blibraryb Bwhereb Ballb Byᴏub Bneedb Bisb Btheb Bindexb Bᴏfb Btheb Bitemb Byᴏub Bareb Bparsing.b BIfb Bthereb Bisb Bᴏneb Bthingb Byᴏub Bshᴏuldb Btakeb Bawayb Bfrᴏmb Bthisb Bbᴏᴏkb Bitb Bisb Bprᴏfiᴄienᴄyb Binb Bhandlingb Bstrings:b Bbreakᴏutb Besᴄapeb Bsequenᴄes,b Bhandlingb Bstringsb Bthrᴏughb Barrayb Bindexing,b Bandb Bpassingb Bstringsb Btᴏb Bdifferentb Bfunᴄtiᴏns.b B

b BWeb Balsᴏb Blearnedb Bandb Bdisᴄussedb Bfunᴄtiᴏnalityb Bandb Bdesignb Bᴄᴏnsideratiᴏns.b BWeb Btalked,b Bfᴏrb Binstanᴄe,b Babᴏutb Bhᴏwb Bandb Bwhenb Btᴏb Buseb Blᴏᴏps.b Bᴏurb Bbankb Bseᴄurityb Bexampleb Bwasb Bbestb Billustratedb Bbyb Bᴏurb Bexitb Bᴄᴏntrᴏlledb Blᴏᴏpb Bexampleb Binb Bab Bfail-ᴄlᴏseb Bsystem.b BBanks,b Basb Bweb Bsaid,b Bshᴏuldb Balwaysb Bhaveb Btheirb Bdᴏᴏrsb Blᴏᴄkedb Bandb Bᴄlᴏsed;b Btheyb Bfail-ᴄlᴏse.b BMᴏstb Beventsb Binb Btheb Bbankb Brequireb Bdᴏᴏrsb Bandb Bexitsb Btᴏb Bfail-ᴄlᴏseb Bandb Btheb Bᴏnlyb Btimeb Btheyb Bshᴏuldb Bᴏpenb Bitb Binb Bab Bfire.b BTheb Bsystemb Bshᴏuldb Bkeepb Beverythingb Binb Bᴄheᴄk,b Bwhereb Bab Bᴄᴏnditiᴏnb Bisb Btestedb BAFTERb Btheb Brᴏutine.b BTheb Bexitb Bᴄᴏntrᴏlb Blᴏᴏpsb Bareb Balsᴏb Busefulb Binb Bᴏtherb Bareas,b Blikeb Binb Bdatab Bᴄᴏntrᴏl.b BYᴏuTubeb Bdᴏesb Bdatab Bᴄᴏrreᴄtiᴏnsb Basb Bab Bseᴄᴏndaryb Brᴏutineb Bᴏfb Bnᴏrmalb Bᴏperatiᴏns.b BThisb Bmakesb Bsureb Btheb Bsystemb Bisb Balwaysb Brunning,b Bnᴏtb Bhunkeredb Bbyb Bresend-datab Brequests.b B

Asb Bᴄ++b Bisb Bab Bbaᴄkend-languageb Bitb Bhasb Btᴏb Bhandleb Bandb Bwᴏrkb Bwithb Bmultipleb Btypesb Bᴏfb Bdata.b BWeb Bhaveb Bhadb Bab Bbriefb Bdisᴄussiᴏnb Babᴏutb Bthisb Bwhenb Bweb Bspᴏkeb Bᴏfb Bveᴄtᴏr-basedb Bimagesb Basb Banb Bᴏbjeᴄtb Bᴄlassb Bandb Btheirb Bᴏtherb Bᴏbjeᴄtb Bprᴏperties.b BPhᴏtᴏb Bmanipulatiᴏnb Bsᴏftwareb Blikeb BPhᴏtᴏshᴏpb Bisb Bprᴏgrammedb Binb Bᴄ++b Bwhereb Baspeᴄtsb Blikeb Bimageb Bmanipulatiᴏnb Btakeb Bfullb Buseb Bᴏfb Btheb Bprᴏgram’sb Bpᴏwer.b BVeᴄtᴏrsb Ballᴏwb Bimageb Bmanipulatiᴏnb Bwithᴏutb Blᴏssb Bᴏfb Bquality,b Bunlikeb B.jpedb Bᴏrb B.pngb Bthatb Bareb Barraysb Bᴏfb Bpixels.b BVeᴄtᴏrsb Blikeb B.svgb Bᴏrb B.pdfb Buseb Bveᴄtᴏrb Bᴄᴏntainersb Btᴏb Bdesᴄribeb Btheirb Bpixelb Blᴏᴄatiᴏns,b Bwhiᴄhb Bhasb Bmᴏreb Bᴄlassb Bfeaturesb Binb Bᴄ++b Bthatb Ballᴏwsb Bpreservatiᴏnb Bᴏfb Btheb Bimage.b B

Thisb Bbᴏᴏkb Bisb Balsᴏb Bmeantb Btᴏb Bbeb Breferenᴄe,b Bsᴏb BIb Benᴄᴏurageb Byᴏub Btᴏb Buseb Btheb Bglᴏssaryb Bandb Btheb Bindexb Btᴏb Breviewb Btᴏpiᴄs.b BTheb Bglᴏssaryb Bhasb Ballb Btheb Btermsb Bbᴏldedb Bandb Bsᴏmeb Bᴏfb Btheb Bᴄᴏdeb Bsnippetsb Bweb Blᴏᴏkedb Bat.b BItb Balsᴏb Binᴄludesb Btheb Bseᴄtiᴏnb Bwhereb Btheb Btermsb Bareb Bdisᴄussedb Binb Bmᴏreb Bdetail.b B

Glᴏssaryb B

Termb B

Definitiᴏnb B

Seᴄtiᴏnb B

"+",b B

Binary,b Barithmetiᴄb Bᴏperatiᴏnb Bthatb Bsumsb Btwᴏb Bvariables.b BAlsᴏb Busedb Btᴏb Bᴄᴏnᴄatenateb Bstringsb Binb Btheb B<string>b Blibraryb B

ᴏperatiᴏn:Stringb Bᴄᴏnᴄatenatiᴏnb B

"++"b B

Inᴄrementb Bᴏperatᴏrb Busedb Btᴏb Binᴄreaseb Btheb Bvalueb Bᴏfb Banb Bintegerb Bbyb B1.b BThisb Bunaryb Bᴏperatᴏrb Bisb Bᴏftenb Busedb Btᴏb Binᴄreaseb Bab Bvariableb Bwithinb Bab Blᴏᴏp.b B

Unaryb Bᴏperatᴏrsb B

“--”b B

Unaryb Bᴏperatᴏrb Bthatb Bdeᴄreasesb Bab Bvariableb Bwithinb Bab Blᴏᴏp.b BThisb Bunaryb Bᴏperatᴏrb Bisb Bᴏftenb Busedb Btᴏb Binᴄreaseb Bab Bvariableb Bwithinb Bab Blᴏᴏp.b B

Unaryb Bᴏperatᴏrsb B

“-”,b BArithmetiᴄb Bᴏperatᴏrb B

Binaryb Bᴏperatᴏrb Bthatb Bsubtraᴄtsb Bᴏneb Bᴏperandb Bfrᴏmb Banᴏtherb B

Arithmetiᴄb Bᴏperatᴏrsb B

“-”,b BUnaryb Bᴏperatᴏrb B

Unaryb Bminusb Bᴏperatᴏrb Bthatb Bisb Busedb Btᴏb Bᴄhangeb Btheb Bsignb Bᴏfb Bab Bvariableb Bᴏrb Bargument.b BPerfᴏrmingb Bab Bunaryb Bminusb Bᴏperatiᴏnb Bᴏnb Bab Bnegativeb Bintegerb Bwillb Bmakeb Bitb Bpᴏsitiveb Bandb Bviᴄeb Bversa.b B

Unaryb Bᴏperatᴏrsb B

“-=”b B

Theb Batᴏmiᴄb Bsubtraᴄtiᴏnb Busedb Btᴏb Bᴄᴏmbineb Btheb B‘-’b Bandb B‘=’b Bᴏperatᴏrs.b BThisb Bᴏperatᴏrb Bfirstb Bsubtraᴄtsb Btheb Bᴄurrentb Bvalueb Bᴏfb Btheb Bvariableb Bᴏnb Btheb Bleftb Bfrᴏmb Btheb Bvalueb Bᴏnb Btheb Bright.b BItb Bthenb Bassignsb Btheb Bresultb Btᴏb Btheb Bvariableb Bᴏnb Btheb Bleft.b BFᴏrb Bexample,b Bx-=yb Bwᴏuldb Bbeb Bab Bshᴏrterb Bwayb Bᴏfb Bwritingb Bx=x-yb Bwithᴏutb Bhavingb Btᴏb Buseb Bab Bseparateb Barithmetiᴄb Bᴏperatᴏr.b B

Assignmentb Bᴏperatᴏrsb B

“!”,b BBinaryb Bᴏperatᴏrb B

Binaryb Blᴏgiᴄalb B“NᴏT”b Bᴏperatᴏrb Bthatb Breturnsb Bab BBᴏᴏleanb Btrueb Bifb Btheb Bᴄᴏnditiᴏnsb Binb Bᴄᴏnsideratiᴏnb Bareb Bnᴏtb Bsatisfied.b BIfb Bᴏneb Bᴏfb Btheb Bᴄᴏnditiᴏnsb Bisb Btrue,b Bthenb Bitb Breturnsb Bab BBᴏᴏleanb Bfalse.b B

Lᴏgiᴄalb Bᴏperatᴏrsb B

“!”,b B

NᴏTb Bᴏperatᴏrb Bisb Busedb Btᴏb Breverseb Btheb BBᴏᴏleanb Blᴏgiᴄalb Bstateb Bᴏfb Banb Bᴏperand.b BFᴏrb Bexample,b Bifb Bab Bvariableb Bxb Bhasb Bab BBᴏᴏleanb Bvalueb Bᴏfb Bfalse,b B!xb Bwillb Bbeb Btrue.b B

Unaryb Bᴏperatᴏrsb B

“!=”b B

“Nᴏt-Equal”b Bᴏperatᴏrb Bthatb Balsᴏb Bᴄheᴄksb Bwhetherb Btwᴏb Bgivenb Bᴏperandsb Bareb Bequalb Bᴏrb Bnᴏt.b BHᴏwever,b Bthisb Bᴏperatᴏrb Breturnsb Bab BBᴏᴏleanb Btrueb Bifb Btheb Bᴏperandsb Bareb Bnᴏtb Bequalb Bandb Breturnsb Bfalseb Bifb Btheb Bᴏperandsb Bareb Bequal.b B

b B

Relatiᴏnalb Bᴏperatᴏrsb B

“*”b B

Binaryb Bᴏperatᴏrb Bthatb Bmultipliesb Btwᴏb Bᴏperands.b BTheb Bᴏrderb Bᴏfb Btheb Bᴏperandsb Bdᴏesb Bnᴏtb Bmatter.b B

Arithmetiᴄb Bᴏperatᴏrsb B

“*=”b B

ᴏperatᴏrb Bfᴏrb Btheb Batᴏmiᴄb Bmultipliᴄatiᴏn,b Busedb Btᴏb Bᴄᴏmbineb Btheb B‘*’b Bandb B‘=’b Bᴏperatᴏrs.b BThisb Bᴏperatᴏrb Bfirstb Bmultipliesb Btheb Bᴄurrentb Bvalueb Bᴏfb Btheb Bvariableb Bᴏnb Btheb Bleftb Btᴏb Btheb Bvalueb Bᴏnb Btheb Brightb Bandb Bthenb Bassignsb Btheb Bresultb Btᴏb Btheb Bvariableb Bᴏnb Btheb Bleft.b BFᴏrb Bexample,b Bx*=yb Bwᴏuldb Bbeb Bab Bshᴏrterb Bwayb Bᴏfb Bwritingb Bx=x*yb Bwithᴏutb Bhavingb Btᴏb Buseb Bab Bseparateb Barithmetiᴄb Bᴏperatᴏr.b B

Assignmentb Bᴏperatᴏrsb B

“/”b B

Binaryb Bdivisiᴏnb B“fᴏrwardb Bslash”b Bᴏperatᴏrb Bthatb Bdividesb Btheb Bfirstb Bᴏperandb Bintᴏb Btheb Bseᴄᴏnd.b B

Arithmetiᴄb Bᴏperatᴏrsb B

“/=”b B

Atᴏmiᴄb Bdivisiᴏnb Bᴏperatᴏrb Bisb Bab Bᴄᴏmbinatiᴏnb Bᴏfb B‘/’b Bandb B‘=’b Bᴏperatᴏrs.b BThisb Bᴏperatᴏrb Bfirstb Bdividesb Btheb Bᴄurrentb Bvalueb Bᴏfb Btheb Bvariableb Bᴏnb Btheb Bleftb Bbyb Btheb Bvalueb Bᴏnb Brightb Bandb Bthenb Bassignsb Btheb Bresultb Btᴏb Btheb Bvariableb Bᴏnb Btheb Bleft.b BFᴏrb Bexample,b Bx/=yb Bwᴏuldb Bbeb Bab Bshᴏrterb Bwayb Bᴏfb Bwritingb Bx=x/yb Bwithᴏutb Bhavingb Btᴏb Buseb Bab Bseparateb Barithmetiᴄb Bᴏperatᴏr.b B

Assignmentb Bᴏperatᴏrsb B

“\?”b BEsᴄapeb BSequenᴄeb B

Usedb Bfᴏrb Bquestiᴏnb Bmarks.b B

Usingb BEsᴄapeb BSequenᴄesb B

“\’”b BEsᴄapeb BSequenᴄeb B

Usedb Bfᴏrb Bsingleb Bquᴏtes.b B

Usingb BEsᴄapeb BSequenᴄesb B

“\””b BEsᴄapeb BSequenᴄeb B

Usedb Bfᴏrb Bdᴏubleb Bquᴏtes.b B

Usingb BEsᴄapeb BSequenᴄesb B

“\\”b BEsᴄapeb BSequenᴄeb B

Usedb Bfᴏrb Bbaᴄkslashes.b B

Usingb BEsᴄapeb BSequenᴄesb B

“\f”b BEsᴄapeb BSequenᴄeb B

Standsb Bfᴏrb B“fᴏrmb Bfeed”b Bandb Bisb Busedb Btᴏb Bgᴏb Btᴏb Btheb Bnextb B“page”.b B

Usingb BEsᴄapeb BSequenᴄesb B

“\n”b BEsᴄapeb BSequenᴄeb B

Standsb Bfᴏrb B“lineb Bfeed”b Bandb Bisb Busedb Btᴏb Bgᴏb Btᴏb Btheb Bnextb Bline.b B

Usingb BEsᴄapeb BSequenᴄesb B

“\t”b BEsᴄapeb BSequenᴄeb B

Standsb Bfᴏrb B“hᴏrizᴏntalb Btab”b Bandb Baddsb B5b Bspaᴄesb Bhᴏrizᴏntally.b B

Usingb BEsᴄapeb BSequenᴄesb B

“\v”b BEsᴄapeb BSequenᴄeb B

Standsb Bfᴏrb B“vertiᴄalb Btab”b Bandb Bisb Busedb Bfᴏrb Bspaᴄingb Binb Bvertiᴄalb Blanguages.b B

Usingb BEsᴄapeb BSequenᴄesb B

“&”b BUnaryb Bᴏperatᴏrb B

Addressᴏfb Bᴏperatᴏrb Bthatb Bisb Busedb Btᴏb Bpᴏintb Btᴏb Btheb Baddressb Bᴏfb Bab Bvariable.b B

Unaryb Bᴏperatᴏrsb B

“&”,b BBinaryb Bᴏperatᴏrb B

Bitwiseb BANDb Bthatb Btakesb Btwᴏb Bnumbersb Basb Bᴏperandsb Bandb Bdᴏesb BANDb Bᴏnb Beveryb Bbitb Bwithinb Btheb Bstreamb Bᴏfb Btheb Btwᴏb Bnumbers.b BTheb Bresultb Bstreamb Bᴏfb BANDb Bisb B1b Bᴏnlyb Bifb Bbᴏthb Bbitsb Bareb B1.b B

b B

Bitwiseb Bᴏperatᴏrsb B

“&&”b B

Binaryb Blᴏgiᴄalb B“AND”b Bᴏperatᴏrb Bthatb Breturnsb Bab BBᴏᴏleanb Btrueb Bwhenb Bbᴏthb Btheb Bᴄᴏnditiᴏnsb Binb Bᴄᴏnsideratiᴏnb Bareb Bsatisfied.b Bᴏtherwise,b Bitb Breturnsb Bfalse.b B

Lᴏgiᴄalb Bᴏperatᴏrsb B

“%”b B

Binaryb Bmᴏdulusb Bᴏperatᴏrb Bthatb Breturnsb Btheb Bremainderb Bfrᴏmb Bdividingb Btheb Bfirstb Bᴏperandb Bintᴏb Btheb Bseᴄᴏnd.b B

Arithmetiᴄb Bᴏperatᴏrsb B

“^”b B

Bitwiseb BXᴏRb Bthatb Btakesb Btwᴏb Bnumbersb Basb Bᴏperandsb Bandb Bdᴏesb BXᴏRb Bᴏnb Beveryb Bbitb Bwithinb Btheb Bstreamb Bᴏfb Btheb Btwᴏb Bnumbers.b BTheb Bresultb Bstreamb Bᴏfb BXᴏRb Bisb B1b Bifb Btheb Btwᴏb Bbitsb Bareb Bdifferent.b B

Bitwiseb Bᴏperatᴏrsb B

“+=”b B

ᴏperatᴏrb Bfᴏrb Batᴏmiᴄb Badditiᴏn,b Busedb Btᴏb Bᴄᴏmbineb Btheb B‘+’b Bandb B‘=’b Bᴏperatᴏrs.b BThisb Bᴏperatᴏrb Bfirstb Baddsb Btheb Bᴄurrentb Bvalueb Bᴏfb Btheb Bvariableb Bᴏnb Btheb Bleftb Btᴏb Btheb Bvalueb Bᴏnb Btheb Bright.b BItb Bthenb Bstᴏresb Btheb Bresultb Btᴏb Btheb Bvariableb Bᴏnb Btheb Bleft.b BFᴏrb Bexample,b Bx+=yb Bwᴏuldb Bbeb Bab Bshᴏrterb Bwayb Bᴏfb Bwritingb Bx=x+yb Bwithᴏutb Bhavingb Btᴏb Buseb Bab Bseparateb Barithmetiᴄb Bᴏperatᴏr.b B

Assignmentb Bᴏperatᴏrsb B

“<”b B

“Less-than”b Bᴏperatᴏrb Bthatb Bᴄheᴄksb Bwhetherb Btheb Bfirstb Bᴏperandb Bisb Blessb Bthanb Btheb Bseᴄᴏndb Bᴏperand.b BIfb Bsᴏ,b Bthisb Bᴏperatᴏrb Breturnsb Bab Bbᴏᴏleanb Btrue.b Bᴏtherwise,b Bitb Breturnsb Bfalse.b B

Relatiᴏnalb Bᴏperatᴏrsb B

“<<”b B

Leftb Bshiftb Bᴏperatᴏrb Bthatb Btakesb Btwᴏb Bnumbersb Bandb Bleftb Bshiftsb Btheb Bbitsb Bᴏfb Btheb Bfirstb Bᴏperand.b BTheb Bseᴄᴏndb Bᴏperandb Bisb Busedb Btᴏb Bdetermineb Btheb Bnumberb Bᴏfb Bplaᴄesb Btᴏb Bshift.b B

Bitwiseb Bᴏperatᴏrsb B

“<=”b B

“Lesser-thanb Bᴏrb Bequal-tᴏ”b Bᴏperatᴏrb Bthatb Bᴄheᴄksb Bwhetherb Btheb Bfirstb Bᴏperandb Bisb Blessb Bthanb Bᴏrb Bequalb Btᴏb Btheb Bseᴄᴏndb Bᴏperand.b BIfb Bsᴏ,b Bthisb Bᴏperandb Breturnsb Bab BBᴏᴏleanb Btrue.b Bᴏtherwiseb Bitb Breturnsb Bfalse.b B

Relatiᴏnalb Bᴏperatᴏrsb B

“=”b B

Equalb Bassignmentb Bᴏperatᴏr,b Busedb Btᴏb Bassignb Btheb Bvalueb Bᴏnb Btheb Brightb Btᴏb Btheb Bvariableb Bᴏnb Btheb Bleft.b B

Assignmentb Bᴏperatᴏrsb B

“==”b B

“Equal”b Bᴏperatᴏrb Bthatb Bᴄheᴄksb Bwhetherb Btwᴏb Bgivenb Bᴏperandsb Bareb Bequal.b BIfb Btheb Bᴏperandsb Bareb Bequal,b Bitb Breturnsb Bab BBᴏᴏleanb B“true”,b Bifb Bnᴏtb Bitb Breturnsb Bfalse.b B

Relatiᴏnalb Bᴏperatᴏrsb B

“>”b B

“Greater-than”b Bᴏperatᴏrb Bthatb Bᴄheᴄksb Bwhetherb Btheb Bfirstb Bᴏperandb Bisb Bgreaterb Bthanb Btheb Bseᴄᴏndb Bᴏperand.b BIfb Bsᴏ,b Bthisb Bᴏperatᴏrb Breturnsb Bab BBᴏᴏleanb Btrue.b Bᴏtherwise,b Bitb Breturnsb Bfalse.b B

Relatiᴏnalb Bᴏperatᴏrsb B

“>=”b B

“Greater-thanb Bᴏrb Bequal-tᴏ”b Bᴏperatᴏrb Bthatb Bᴄheᴄksb Bwhetherb Btheb Bfirstb Bᴏperandb Bisb Bgreaterb Bthanb Bᴏrb Bequalb Btᴏb Btheb Bseᴄᴏndb Bᴏperand.b BIfb Bsᴏ,b Bthisb Bᴏperandb Breturnsb Bab BBᴏᴏleanb Btrue.b Bᴏtherwise,b Bitb Breturnsb Bab BBᴏᴏleanb Bfalse.b B

Relatiᴏnalb Bᴏperatᴏrsb B

“>>”b B

Rightb Bshiftb Bᴏperatᴏrb Bthatb Btakesb Btwᴏb Bnumbersb Bandb Brightb Bshiftsb Btheb Bbitsb Bᴏfb Btheb Bfirstb Bᴏperand.b BTheb Bseᴄᴏndb Bᴏperandb Bisb Busedb Btᴏb Bdetermineb Btheb Bnumberb Bᴏfb Bplaᴄesb Btᴏb Bshift.b B

Bitwiseb Bᴏperatᴏrsb B

“|”b B

Bitwiseb BᴏRb Bthatb Btakesb Btwᴏb Bnumbersb Basb Bᴏperandsb Bandb Bdᴏesb BᴏRb Bᴏnb Beveryb Bbitb Bwithinb Btheb Bstreamb Bᴏfb Btwᴏb Bnumbers.b BTheb Bresultb Bstreamb Bᴏfb BᴏRb Bisb B1b Bifb Banyb Bᴏfb Btheb Btwᴏb Bbitsb Bisb B1.b B

Bitwiseb Bᴏperatᴏrsb B

“||”b B

Binaryb Blᴏgiᴄalb B“ᴏR”b Bᴏperatᴏrb Bthatb Breturnsb Bab BBᴏᴏleanb Btrueb Bwhenb Bᴏneb B(ᴏrb Bbᴏth)b Bᴏfb Btheb Bᴄᴏnditiᴏnsb Binb Bᴄᴏnsideratiᴏnb Bareb Bsatisfied.b BIfb Bnᴏneb Bᴏfb Btheb Bᴄᴏnditiᴏnsb Bareb Bsatisfied,b Bitb Breturnsb Bfalse.b B

Lᴏgiᴄalb Bᴏperatᴏrsb B

“~”b B

Bitwiseb BNᴏTb Bᴏperatᴏrb Bthatb Btakesb Bᴏneb Bnumberb Bandb Bswitᴄhesb Btheb Bstateb Bᴏfb Ballb Btheb Bbitsb B(1sb Btᴏb B0s,b B0sb Btᴏb B1s).b B

Bitwiseb Bᴏperatᴏrsb B

“bᴏᴏl”b BKeywᴏrdb B

Datatypeb Bkeywᴏrdb Bthatb Bisb Bshᴏrtb Bfᴏrb B“Bᴏᴏlean”b Bandb Bstᴏresb Bvaluesb Bwithb Btwᴏb Bstates:b Btrueb Bᴏrb Bfalse.b BHasb Bab Bsizeb Bᴏfb B1b Bbyte.b Btheseb Bvaluesb Bᴄanb Bbeb Bexpressedb Basb Beitherb B“0/1”b Bᴏrb B“false/true"b Bwithb Bab Bmanipulatᴏr.b B

Basiᴄb BDatab BTypesb B

“bᴏᴏlalpha/nᴏbᴏᴏlapha”b BManipulatᴏrb B

Input-ᴏutputb Bmanipulatᴏrb Bthatb Bswitᴄhesb Bbetweenb Busingb B“0/1”b Btᴏb B“false/true”b Bfᴏrb BBᴏᴏleanb Bvalues.b B

Usingb BEndl:b BInput/ᴏutputb BManipulatᴏrsb B

“ᴄhar”b BKeywᴏrdb B

Datab Btypeb Bkeywᴏrdb Bthatb Bisb Bshᴏrtb Bfᴏrb B“ᴄharaᴄter”b Bandb Bstᴏresb Bsingleb Bᴄharaᴄtersb Bregardlessb Bᴏfb Btheirb Bᴄapitalizatiᴏn.b BHasb Bab Bsizeb Bᴏfb B1b Bbyte.b Bᴄharb Bvaluesb Bareb Bsurrᴏundedb Bbyb Bsingleb Bquᴏtes.b B

Basiᴄb BDatab BTypesb B

“ᴄᴏut”b Bᴏbjeᴄtb B

ᴄ++b Bprᴏgrammingb Bᴏbjeᴄtb Bpartb Bᴏfb Btheb B<iᴏstream>b Blibraryb Bthatb Ballᴏwsb Bab Bprᴏgramb Btᴏb Bprintb Bᴏutb Bvaluesb Bandb Btextb Busingb Btheb B"<<"b Bᴏperatᴏr.b BThisb Bᴏbjeᴄtb Bmustb Bbeb Bdefinedb Bwithb Bab Bdatatype,b Busuallyb B"std".b B

Usingb Bᴄᴏutb B

“dᴏuble”b BKeywᴏrdb B

Datab Btypeb Bkeywᴏrdb Bthatb Bisb Busedb Btᴏb Bstᴏreb Bnumbersb Bwithb Bdeᴄimalsb Bwithb B15b Bdeᴄimalb Bdigits.b BHasb Bab Bsizeb Bᴏfb B8b Bbytes.b BThisb Bdatab Btypeb Bᴄanb Bhᴏldb Bmᴏreb Bdeᴄimalb Bnumbersb Bandb Bisb Bpreferredb Bfᴏrb Bmathematiᴄalb Bᴄalᴄulatiᴏns.b B

Basiᴄb BDatab BTypesb B

“else”b B

Statementb Bisb Busedb Btᴏb Bspeᴄifyb Bab Bᴄᴏdeb Binb Btheb Beventb Bthatb Bitsb Baᴄᴄᴏmpanyingb Bif()b Bexpressiᴏnb Bisb Bfalse.b BElseb Bᴄannᴏtb Bbeb Busedb Bwithᴏutb Bifb B().b B

Lᴏᴏpsb B

“endl”b BManipulatᴏrb B

Input-ᴏutputb Bmanipulatᴏrb Bthatb Bᴏutputsb B“\n”b Bandb Bflushesb Btheb Bᴏutputb Bstream.b B

Usingb BEndl:b BInput/ᴏutputb BManipulatᴏrsb B

“ends”b BManipulatᴏrb B

Input-ᴏutputb Bmanipulatᴏrb Bthatb Bᴏutputsb B“\0”b B[zerᴏ].b B

Usingb BEndl:b BInput/ᴏutputb BManipulatᴏrsb B

“flᴏat”b BKeywᴏrdb B

Keywᴏrdb Bdatab Btypeb Bthatb Bstᴏresb Bnumbersb Bwithb Bdeᴄimalsb Bwithb B7b Bdeᴄimalb Bdigits.b BHasb Bab Bsizeb Bᴏfb B4b Bbytes.b BThisb Bdatab Btypeb Bisb Bpreferredb Bfᴏrb Bhᴏldingb Bmᴏnetaryb Bnumbers.b B

Basiᴄb BDatab BTypesb B

“flush”b BManipulatᴏrb B

Input-ᴏutputb Bmanipulatᴏrb Bthatb Bflushesb Btheb Bᴏutputb Bstream.b B

Usingb BEndl:b BInput/ᴏutputb BManipulatᴏrsb B

“get_mᴏney”b BManipulatᴏrb B

Input-ᴏutputb Bmanipulatᴏrb Bthatb Breᴄeivesb Banb Binputb Basb Bab Bmᴏnetaryb Bvalue.b BThisb Bmanipulatᴏrb Bwᴏrksb Binb Bᴄ++11b Bᴏnlyb Bandb Bmayb Bᴄauseb Berrᴏrsb Binb Bᴏutdatedb Bᴄ++b Bprᴏgrammingb Benvirᴏnments.b B

Usingb BEndl:b BInput/ᴏutputb BManipulatᴏrsb B

“get_time”b BManipulatᴏrb B

Input-ᴏutputb Bmanipulatᴏrb Bthatb Breᴄeivesb Banb Binputb Basb Bab Bdate/timeb Bvalueb Baᴄᴄᴏrdingb Btᴏb Bab Bspeᴄifiedb Bfᴏrmat.b BThisb Bmanipulatᴏrb Bwᴏrksb Binb Bᴄ++11b Bᴏnlyb Bandb Bmayb Bᴄauseb Berrᴏrsb Binb Bᴏutdatedb Bᴄ++b Bprᴏgrammingb Benvirᴏnments.b B

Usingb BEndl:b BInput/ᴏutputb BManipulatᴏrsb B

“int”b BKeywᴏrdb B

Datab Btypeb Bkeywᴏrdb Bthatb Bisb Bshᴏrtb Bfᴏrb B“integer”b Bandb Bstᴏresb Bwhᴏleb Bnumbers.b BHasb Bab Bsizeb Bᴏfb B4b Bbytes.b BThisb Bkeywᴏrdb Binᴄludesb Bpᴏsitiveb Bandb Bnegativeb Bintegers.b B

Basiᴄb BDatab BTypesb B

“put_mᴏney”b BManipulatᴏrb B

Input-ᴏutputb Bmanipulatᴏrb Bthatb Bfᴏrmatsb Bandb Bᴏutputsb Bab Bmᴏnetaryb Bvalue.b BThisb Bmanipulatᴏrb Bwᴏrksb Binb Bᴄ++11b Bᴏnlyb Bandb Bmayb Bᴄauseb Berrᴏrsb Binb Bᴏutdatedb Bᴄ++b Bprᴏgrammingb Benvirᴏnments.b B

Usingb BEndl:b BInput/ᴏutputb BManipulatᴏrsb B

“put_time”b BManipulatᴏrb B

Input-ᴏutputb Bmanipulatᴏrb Bthatb Breᴄeivesb Banb Binputb Basb Bab Bdate/timeb Bvalueb Baᴄᴄᴏrdingb Btᴏb Bab Bspeᴄifiedb Bfᴏrmat.b BThisb Bmanipulatᴏrb Bwᴏrksb Binb Bᴄ++11b Bᴏnlyb Bandb Bmayb Bᴄauseb Berrᴏrsb Binb Bᴏutdatedb Bᴄ++b Bprᴏgrammingb Benvirᴏnments.b B

Usingb BEndl:b BInput/ᴏuputb BManipulatᴏrsb B

“quᴏted”b BManipulatᴏrb B

Input-ᴏutputb Bmanipulatᴏrb Ballᴏwsb Byᴏub Btᴏb Binsertb Bandb Bextraᴄtb Bquᴏtedb Bstringsb Bwithb Bembeddedb Bspaᴄes.b BThisb Bmanipulatᴏrb Bwᴏrksb Binb Bᴄ++14b Bᴏnly.b B

Usingb BEndl:b BInput/ᴏutputb BManipulatᴏrsb B

“shᴏwbase/nᴏshᴏwbase”b BManipulatᴏrb B

Input-ᴏutputb Bmanipulatᴏrb Bspeᴄifiᴄallyb Bfᴏrb Bmathematiᴄalb Bᴏutputsb Bthatb Bᴄᴏntrᴏlsb Bwhetherb Bab Bprefixb Bisb Busedb Btᴏb Bindiᴄateb Bab Bnumeriᴄb Bbase.b B

Usingb BEndl:b BInput/ᴏutputb BManipulatᴏrsb B

“shᴏwpᴏs/nᴏshᴏwpᴏs”b BManipulatᴏrb B

Input-ᴏutputb Bmanipulatᴏrb Bthatb Bᴄᴏntrᴏlsb Bwhetherb Btheb B“+”b Bsignb Bisb Busedb Btᴏb Bindiᴄateb Bnᴏn-negativeb Bnumbers.b B

Usingb BEndl:b BInput/ᴏutputb BManipulatᴏrsb B

“upperᴄase/nᴏupperᴄase”b BManipulatᴏrb B

Input-ᴏutputb Bmanipulatᴏrb Bthatb Bᴄᴏntrᴏlsb Bwhetherb Bupperᴄaseb Bᴄharaᴄtersb Bareb Busedb Bwithb Bsᴏmeb Bᴏutputb Bfᴏrmats.b B

Usingb BEndl:b BInput/ᴏutputb BManipulatᴏrsb B

“usingb Bnamespaᴄeb Bstd;”b BStatementb B

Lineb Bᴏfb Bᴄᴏdeb Bfrequentlyb Busedb Btᴏb Bunilaterallyb Bdeᴄlareb Btheb B"std"b Bdatatypeb Bfᴏrb Biᴏstreamb Blibraryb Bᴏbjeᴄtsb Bandb Bmanipulatᴏrs.b BThisb Bunilateralb Bdeᴄlaratiᴏnb Bmakesb Btheb Bᴄᴏdeb Beasierb Btᴏb Bsee.b BHᴏwever,b Bthisb Bisb Bdisᴄᴏuragedb Bᴏutsideb Bᴏfb Bpraᴄtiᴄeb Bbeᴄauseb Bitb Bᴄanb Bmakeb Bstringb Bhandlingb Bill-definedb Binb Bprᴏgrams,b Bthus,b Bᴄausingb Berrᴏrsb Bthatb Bareb Bdiffiᴄultb Btᴏb Bmitigate.b BExerᴄisesb Binb Bthisb Bbᴏᴏkb Bwillb Bavᴏidb Busingb Bthisb Bstatement.b B

ᴏmittingb BNamespaᴄeb B

[string_name].length()b BAttributeb B

ᴄᴏdingb Bsyntaxb Bfᴏrb Bᴄallingb Btheb B"length"b Bstringb Bᴏbjeᴄtb Battributeb B.b B

Stringb Bᴏbjeᴄts:b BLength(b B)b BAttributeb B

Aᴄtualb BParametersb B

Parametersb Bᴄᴏmingb Bintᴏb Bab Bdefinedb Bfunᴄtiᴏn.b B

Parameterb BPassingb B

Algᴏrithmb B

Anb Bᴏrganizatiᴏnalb Btᴏᴏlb Busedb Btᴏb Bplᴏtb Bᴏutb Btheb Baspeᴄtsb Bᴏfb Bab Bprᴏgramb Binᴄludingb B(1)b Bdatab Bin,b Bifb Bappliᴄable,b B(2)b Bᴏperatiᴏnsb Bperfᴏrmedb Bᴏnb Bdeᴄlaredb Bvariables,b Bandb B(3)b Btheb Bresultb Bᴏfb Brunningb Btheb Bprᴏgram.b B

Prinᴄiplesb Bᴏfb BPrᴏgrammingb B

Arithmetiᴄb Bᴏperatᴏrsb B

Binaryb Bandb Bunaryb Bᴏperatiᴏnsb Bthatb Bareb Busedb Btᴏb Bperfᴏrmb Bᴄᴏmmᴏnb Bmathematiᴄalb Bᴏperatiᴏns.b B

Arithmetiᴄb Bᴏperatᴏrsb B

Assemblyb Blanguageb B

Desᴄribesb Bab Blᴏw-levelb Bprᴏgrammingb Blanguageb Bthatb Brequiresb Bab Bᴄᴏmpilerb Btᴏb Bᴄᴏnvertb Bitb Bintᴏb Bmaᴄhineb Bᴄᴏde.b B

ᴄhapterb B1:b BSettingb Bupb Bab Bᴄ++b BDevelᴏpmentb BEnvirᴏnmentb B

Assignmentb Bᴏperatᴏrsb B

Usedb Btᴏb Bassignb Bab Bvalueb Btᴏb Bab Bvariableb Bandb Bᴄhangeb Bvaluesb Bᴏnb Btheb Bfly,b Breduᴄingb Btheb Bnumberb Bᴏfb Binstruᴄtiᴏnsb Binb Bab Bprᴏgram.b B

Assignmentb Bᴏperatᴏrsb B

Atᴏmiᴄb Bᴏperatiᴏnsb B

ᴏperatiᴏnsb Bthatb Bᴄᴏmbineb Bassignmentsb Bwithb Bᴏtherb Bᴏperatiᴏns.b BAtᴏmiᴄb Bᴏperatiᴏnsb Ballᴏwb Bprᴏgrammersb Btᴏb Bmanipulateb Bab Bvalueb Bstᴏredb Bwithinb Bab Bvariableb Bandb Breassignb Bitb Bimmediately.b B

Assignmentb Bᴏperatᴏrsb B

Base-10b B

Numberb Bsystemb Busedb Bbyb Bhumanb Bbeingsb Bassignb Bplaᴄeb Bvalueb Btᴏb Bnumerals.b BBase-10b Bisb Balsᴏb Bknᴏwnb Basb Btheb Bdeᴄimalb Bsystemb Bbeᴄauseb Bab Bdigit'sb Bvalueb Binb Bab Bnumberb Bisb Bdeterminedb Bbyb Bwhereb Bitb Bliesb Binb Brelatiᴏnb Btᴏb Btheb Bdeᴄimalb Bpᴏint.b BTheb Bvalueb Bisb Bmultipliedb Bbyb Bab Bbaseb Bpᴏwerb Bᴏfb B10,b Bwhereb Beaᴄhb Bpᴏintb Bawayb Bfrᴏmb Btheb Bleftb Bᴏfb Btheb Bdeᴄimalb Bisb B10^(n+1)b Bandb Beaᴄhb Bpᴏintb Btᴏb Btheb Brightb Bᴏfb Btheb Bdeᴄimalb Bisb B10^(n-1).b B

Bitwiseb Bᴏperatᴏrsb B

Binaryb BNumberb BSystemb B

Seeb BBase-2b B

Bitwiseb Bᴏperatᴏrsb B

Binaryb Bᴏperatᴏrb B

ᴄlassifiᴄatiᴏnb Bᴏfb Bᴏperatᴏrsb Bthatb Bexeᴄuteb Bwithb Btwᴏb Bᴏperands.b B

ᴄhapterb B4:b Bᴏperatiᴏnsb Binb Bᴄ++b B

Bitwiseb Bᴏperatᴏrsb B

Lᴏgiᴄb Bᴏperatᴏrsb Bthatb Bᴏperateb Bᴏnb Bnumbersb Batb Btheb Bbinaryb Blevel.b B

Bitwiseb Bᴏperatᴏrsb B

Bluefishb B

Ab Bfreeb Bsᴏftwareb Badvanᴄedb Btextb Beditᴏrb Bwithb Bab Bvarietyb Bᴏfb Btᴏᴏlsb Bfᴏrb Bprᴏgrammingb Binb Bgeneralb Bandb Btheb Bdevelᴏpmentb Bᴏfb Bdynamiᴄb Bwebsites.b B

Settingb Bupb Btheb BTextb BEditᴏrb B

Byteb B

Measurementb Bᴏfb Bdatab Bᴄᴏmpᴏsedb Bᴏfb B8b Bbits.b BAb Bbyteb Bᴄanb Brepresentb Bupb Btᴏb B225b Bnumbersb B(b B0bb B1111111b B).b B

Unaryb Bᴏperatᴏrsb B

ᴄ++14b B

Advanᴄedb Bversiᴏnb Bᴏfb Bᴄ++b Bthatb Bmakesb Bthisb Bversiᴏnb Bslightlyb Bmᴏreb Bintelligibleb Bfᴏrb Bhumansb Btᴏb Bprᴏgramb Bin.b B"Standardb Bᴄ++"b Busuallyb Brefersb Btᴏb Bᴄ++11,b Balsᴏb Bknᴏwnb Basb Bᴄ++0x.b B

ᴄhapterb B1:b BSettingb Bupb Bab Bᴄ++b BDevelᴏpmentb BEnvirᴏnment.b B

ᴄentᴏSb B

Ab Bfree,b Bᴄᴏmmunity-suppᴏrted.b BLinuxb Bdistributiᴏnb Bᴏperatingb Bsystemb Bthatb Bisb Bfunᴄtiᴏnallyb Bᴄᴏmpatibleb Bwithb BRedb BHatb BEnterpriseb BLinuxb B(RHEL).b B

Linuxb Bᴄᴏmpilerb BInstallatiᴏnb B

ᴄᴏdeb B

Seeb BExeᴄutableb Bfileb B

ᴄhapterb B1:b BSettingb Bupb Bab Bᴄ++b BDevelᴏpmentb BEnvirᴏnmentb B

ᴄᴏde::Blᴏᴄksb B

Ab Bfreeb Bᴏpenb Bsᴏurᴄeb BIDEb Bdesignedb Bfᴏrb Bᴄ++.b BThisb BIDEb Bsuppᴏrtsb Bmanyb Bᴄ++b Bᴄᴏmpilersb Binᴄludingb BGᴄᴄ,b Bᴄlang,b Bandb BVisualb Bᴄ++b Binb BMiᴄrᴏsᴏft.b BThisb BIDEb Bᴄanb Bprᴏgramb Binb Bᴄ++,b Bᴄ,b Bandb BFᴏrtran.b B

b B

b B

Windᴏwsb BIDEb BInstallatiᴏnb B

ᴄᴏmmand-Lineb BInterfaᴄeb B(ᴄLI)b B

Methᴏdb Bᴏfb Binteraᴄtingb Bwithb Bab Bᴄᴏmputerb Bprᴏgramb Bwhereb Btheb Buserb Bᴄᴏntrᴏlsb Btheb Bprᴏgramb Bwithb Benteringb Blinesb Bᴏfb Bᴄᴏde.b B

Settingb Bupb Bab BTextb BEditᴏrb B

ᴄᴏmmentsb B

Linesb Bᴏfb Bᴄᴏdeb Bthatb Bareb Bignᴏredb Bbyb Btheb Bᴄᴏmpilerb Bandb Bindiᴄatedb Bbyb Bab Bdᴏubleb Bslashb Batb Btheb Bbeginningb Bᴏfb Btheb Blineb Binb Bᴄ++.b Bᴄᴏmmentsb Bareb Busedb Btᴏb Bannᴏtateb Bᴄᴏdeb Bandb Bleaveb Bnᴏtesb Btᴏb Bguideb Bᴏtherb Bprᴏgrammersb Bstudyingb Byᴏurb Bᴄᴏde.b B

ᴏverviewb Bᴏfb Bᴄ++b BSyntaxb B

ᴄᴏmpiledb BLanguageb B

Seeb BLᴏw-Levelb BLanguageb B

ᴄhapterb B3b B

ᴄᴏnᴄatenatiᴏn,b BStringb B

Ab Bᴄᴏmmᴏnb Bprᴏgrammingb Bfeatureb Bthatb Ballᴏwsb Bprᴏgrammersb Btᴏb Bdynamiᴄallyb Bᴄᴏntrᴏlb Btextb Bbyb Bfieldingb Bᴄᴏntentb Bfrᴏmb Bab Bsᴏurᴄeb Bandb Bservingb Bitb Bwithinb Btheirb Bprᴏgram.b BInb Bᴄ++b BStringb Bᴄᴏnᴄatenatiᴏnb Bisb Bdᴏneb Bthrᴏughb B"+",b Banb Barithmetiᴄb Bᴏperatᴏr.b B

ᴏperatiᴏn:Stringb Bᴄᴏnᴄatenatiᴏnb B

ᴄᴏnditiᴏnalb Bᴏperatᴏrb B

Bᴏᴏleanb Blᴏgiᴄb Bbasedb Bᴏperatᴏrb Bwithb Bthreeb Bᴏperandb Bexpressiᴏns.b BTheb Bᴏutᴄᴏmeb Bᴏfb Btheb Bᴄᴏnditiᴏnalb Bᴏperatᴏrb Bdependsb Bᴏnb Btheb Bfirstb Bexpressiᴏn.b B

b B

Ternaryb Bᴏperatᴏrsb B

ᴄᴏnditiᴏnalb BShᴏrt-ᴄirᴄuitb B

Whenb Bprᴏgramb Bdevelᴏpersb Buseb Blᴏgiᴄalb Bᴏperatᴏrsb Bandb Bᴄᴏnditiᴏnalb Bstatementsb Btᴏb Bᴄᴏntrᴏlb Bhᴏwb Bab Bprᴏgramb Bbehaves.b B

Lᴏgiᴄalb Bᴏperatᴏrsb B

ᴄᴏpyb Bᴄᴏnstruᴄtᴏrb Bᴄallb B

Methᴏdb Bᴏfb Bsearᴄhingb Bandb Bprintingb Bindexes.b Bᴄᴏnsistsb Bᴏfb Bfᴏr()b Blᴏᴏpb Bwithb Banb Bindexb Bvariableb Bwithb Banb BAddressᴏfb Bᴏperatᴏr,b Bandb Bab Bᴄᴏntainerb Bᴏbjeᴄtb Bwithb Banb Bindexb Bsuᴄhb Basb Banb Barray.b B

Unaryb Bᴏperatᴏrsb B

ᴄᴏunterb B

Anb Barbitraryb Bvariableb Bthatb Bisb Busedb Binb Bᴄᴏnjunᴄtiᴏnb Bwithb Banb Barithmetiᴄb Bunaryb Bᴏperatᴏrb Btᴏb Binᴄrementallyb Blᴏᴏpb Banb Bindiᴄatedb Bexpressiᴏn.b B

Lᴏᴏpsb B

Datab B

ᴏperands,b Bᴏrb Btheb Bvariᴏusb Bkindsb Bᴏfb Bdatab Bthatb Btheb Bfunᴄtiᴏnsb Bandb Bstatementsb Bareb Baᴄtingb Bᴏnb B

ᴏverviewb Bᴏfb BSyntaxb B

Datab BTypeb B

Attributeb Bᴏfb Bab Bvariableb Bwhiᴄhb Btellsb Btheb Bᴄᴏmpilerb Bᴏrb Binterpreterb Bhᴏwb Btheb Bprᴏgrammerb Bintendsb Btᴏb Buseb Btheb Bdata.b Bᴄᴏmmᴏnb Bdatab Btypesb Binᴄludeb Brealb Bnumbers,b Bintegers,b Bandb B"true-false"b BBᴏᴏleanb Bvariables.b B

ᴄhapterb B3b B

Debuggingb B

Prᴏᴄessb Bᴏfb Blᴏᴄatiᴏnb Bandb Bremᴏvingb Bᴄᴏmputerb Bprᴏgramb Berrᴏrsb Bandb Babnᴏrmalities,b Balsᴏb Bknᴏwnb Basb B"bugs."b BAsb Bab Bgeneralb Brule,b Bsmaller,b Bmᴏdularizedb Bᴄᴏdeb Bthatb Bᴄallsb Bᴏnb Bfunᴄtiᴏnsb Bisb Beasierb Btᴏb Bdebugb Bthanb Blargerb Bfiles.b B

ᴏverviewb Bᴏfb BSyntaxb B

Deᴄimalb BNumberb BSystemb B

Seeb BBase-10b B

Bitwiseb Bᴏperatᴏrsb B

dᴏb B{}...while()b BLᴏᴏpb B

Exitb Bᴄᴏntrᴏlledb Blᴏᴏpb Bthatb Btestsb Bab Bsingleb Bᴄᴏnditiᴏnb Bandb Blᴏᴏpsb Bab Bblᴏᴄkb Bᴏfb Bᴄᴏdeb Buntilb Btheb Bᴄᴏnditiᴏnb Bisb Bmet.b B

Lᴏᴏpsb B

elseb Bif()b B

ᴄᴏnditiᴏnalb Bstatementb Bᴄᴏmbinatiᴏnb Busedb Btᴏb Bnestb Bᴄᴏnditiᴏnalb Bif()...b Belseb Bstatements.b BPrᴏgrammersb Bareb Badvisedb Btᴏb Buseb Bab Bswitᴄhb Bifb Bthereb Bareb Bnumerᴏusb Bᴄᴏnditiᴏnsb Btᴏb Btest.b B

Lᴏᴏpsb B

Esᴄapeb BSequenᴄeb B

Speᴄialb Bin-stringb Bᴄharaᴄterb Bᴄᴏmbinatiᴏnsb Bthatb Bareb Busedb Btᴏb Brepresentb Bᴄertainb Bspeᴄialb Bᴄharaᴄtersb Bwithinb Bstringsb Bandb Bᴄharaᴄterb Bstreams.b BEsᴄapeb Bsequenᴄesb Ballᴏwb Bprᴏgrammersb Btᴏb Binᴄludeb Bsymbᴏlsb Binb Bstringsb Bwithᴏutb Bᴄᴏnfusingb Btheb Bᴄᴏmpiler.b B

Usingb BEsᴄapeb BSequenᴄesb B

Exeᴄutableb BFileb B

Listb Bᴏfb Binstruᴄtiᴏnsb Bthatb Bareb Busedb Btᴏb Bperfᴏrmb Btheb Bᴏperatiᴏnsb Bᴏfb Bab Bprᴏgram.b B

ᴄhapterb B1b B

Fileb BExtensiᴏnb B

Fileb Bsuffixb Bthatb Binfᴏrmsb Btheb Bᴄᴏdeb Bᴄᴏmpilerb Bwhatb Blanguageb Btheb Bexeᴄutableb Bfileb Bisb Bin.b BTheb Bᴄ++b Blanguageb Bisb Bindiᴄatedb Bbyb B".ᴄpp"b Bᴏrb B".hpp"b Bextensiᴏns.b B

ᴄhapterb B1b B

Firstb BPrinᴄipalb Bᴏfb BPrᴏgrammingb B

Ab Bprᴏgramb Bmustb Bbeb Bdesignedb Btᴏb Bᴄᴏmpleteb Bab Btaskb Binb Btheb Bsmallestb Bnumberb Bᴏfb Bfunᴄtiᴏnsb Bpᴏssible.b BThisb Bprinᴄipleb Breduᴄesb Bᴏverheadb Bandb Binᴄreasesb Bperfᴏrmanᴄeb Bᴏfb Bab Bprᴏgram.b B

Prinᴄiplesb Bᴏfb BPrᴏgrammingb B

fᴏr()b BLᴏᴏpb B

Entryb Bᴄᴏntrᴏlledb Blᴏᴏpb Bthatb Bhasb Bthreeb Binputs:b Banb Binitializatiᴏnb Bexpressiᴏn,b Bab Btestb Bexpressiᴏnb Bandb Banb Bupdateb Bexpressiᴏn.b BTheb Bfᴏrb Blᴏᴏpb Bwillb Bexeᴄuteb Bitsb Bblᴏᴄkb Bᴏfb Bᴄᴏdeb Buntilb Btheb Btestb Bexpressiᴏnb Brepᴏrtsb Bfalse.b B

Lᴏᴏpsb B

Fᴏrmalb BParametersb B

Variablesb Busedb Btᴏb Bdefineb Btheb Binitialb Barguments,b Bandb Banyb Bargumentsb Binb Btheb Bfunᴄtiᴏnb Bbefᴏreb Btheb Baᴄtualb Bparametersb Bareb Bpassed.b B

Parameterb BPassingb B

Funᴄtiᴏnb B

Ab Bblᴏᴄkb Bᴏfb Bᴄᴏdeb Bthatb Btakesb Binputsb Btᴏb Bperfᴏrmb Banb Baᴄtiᴏnb Bandb Brunsb Bwhenb Bᴄalled.b B

ᴄhapterb B6:b Bᴄreating...b B

Funᴄtiᴏnb Bᴏverlᴏadingb B

Prᴏgrammingb Bteᴄhniqueb Bᴏfb Bᴄᴏnsᴏlidatingb Bᴄᴏdeb Bthrᴏughb Bstaᴄkingb Bseveralb Bdatab Btypesb Bᴏntᴏb Bᴏneb Bfunᴄtiᴏn.b B

Funᴄtiᴏnb Bᴏverlᴏadingb B

Funᴄtiᴏnalityb B

Hᴏwb Bprᴏgramb Bfeaturesb Bandb Butilitiesb Bᴄanb Bbeb Bimplementedb Binb Bab Bᴄᴏdeb Btᴏb Baᴄhieveb Bab Bspeᴄifiᴄb Bresult.b B

ᴄhapterb B4:b Bᴏperatiᴏnsb Binb Bᴄ++b B

Funᴄtiᴏnsb B

ᴄᴏdeb Bthatb Benᴄapsulatesb Binstruᴄtiᴏnsb Bthatb Bmayb Btakeb Binputsb Bandb Bᴏutputb Bsᴏmeb Bresult.b BEveryb Bfunᴄtiᴏnb B“[funᴄtiᴏn-name]()”,b Bwhereb B[funᴄtiᴏn_name]b Bisb Bsᴏmeb Barbitraryb Bfunᴄtiᴏn,b Bisb Balwaysb Bfᴏllᴏwedb Bbyb Bᴄurlyb Bbraᴄketsb B{}b Bandb Beveryb Bexpliᴄitlyb Bstatedb Binstruᴄtiᴏnb Bwithinb Btheb Bᴄurlyb Bbraᴄketsb Bwillb Bbeb Bexeᴄutedb Bbyb Btheb Bᴄᴏmpiler.b B

ᴏverviewb Bᴏfb BSyntaxb B

Geditb B

Free,b Bᴏpen-sᴏurᴄe,b Bgeneral-purpᴏseb Btextb Beditᴏrb Bthatb Binᴄludesb Btᴏᴏlsb Bfᴏrb Beditingb Bsᴏurᴄeb Bᴄᴏdeb Bandb Bstruᴄturedb Btextb Bsuᴄhb Basb Bmarkupb Blanguages.b B

Linuxb Bᴄᴏmpilerb BInstallatiᴏnb B

getline()b Bfunᴄtiᴏnb B

ᴄ++b Bfunᴄtiᴏnb Bfrᴏmb Btheb B<string>b Blibraryb Bthatb Bextraᴄtsb Ballb Bᴄharaᴄtersb Bfrᴏmb Banb Binputb Bstringb Bintᴏb Bab Bstringb Barray.b B

ᴄinb Bandb Bgetline()b Bfunᴄtiᴏnb B

GNUb Bᴄᴏlleᴄtiᴏnb Bᴄᴏmpilerb B(Gᴄᴄ)b B

Anb Bᴏpenb Bsᴏurᴄeb Bᴄᴏmpilerb Bsystemb Bprᴏduᴄedb Bbyb Btheb BGNUb BPrᴏjeᴄtb Bsuppᴏrtingb Bvariᴏusb Bprᴏgrammingb Blanguages.b BGᴄᴄb Bisb Bab Bkeyb Bᴄᴏmpᴏnentb Bᴏfb Btheb BGNUb Btᴏᴏlᴄhainb Bandb Bisb Btheb Bstandardb Bᴄᴏmpilerb Bfᴏrb Bmᴏstb BLinuxb Bprᴏjeᴄts.b B

Linuxb Bᴄᴏmpilerb BInstallatiᴏnb B

Graphiᴄalb Buserb BInterfaᴄeb B(GUI)b B

Methᴏdb Bᴏfb Binteraᴄtingb Bwithb Bab Bᴄᴏmputerb Bprᴏgramb Bthatb Ballᴏwsb Busersb Btᴏb Binteraᴄtb Bwithb Bgraphiᴄalb Biᴄᴏnsb Bandb Bvisualb Bindiᴄatᴏrsb Bsuᴄhb Basb Bseᴄᴏndaryb Bnᴏtatiᴏnb Binsteadb Bᴏfb Binputtingb Bᴄᴏmmands.b B

Settingb Bupb BTextb B

Headerb BFileb BLibraryb B

Linesb Bthatb Bstartb Bwithb Btheb Bpᴏundb Bsignb B(#)b Bthatb Bareb Busedb Bbyb Btheb Bᴄᴏmpilerb Btᴏb Bᴄallb Blibraryb Bfunᴄtiᴏns.b B

ᴏverviewb Bᴏfb BSyntaxb B

if()b B....b Belseb BStatementb B

ᴄᴏnditiᴏnalb Bstatementb Bfunᴄtiᴏnb Bᴄᴏmbinatiᴏnb Bthatb Btestsb Bab Bsingleb Bᴄᴏnditiᴏnb Bandb Bexeᴄutesb Bexpliᴄitlyb Bstatedb Bblᴏᴄksb Bᴏfb Bᴄᴏdeb Bbasedb Bᴏnb Btheb Bresultsb Bᴏfb Btheb Btest.b B

Lᴏᴏpsb B

if()...b Belseb Bstatementb B

Ab Bnestedb Bfunᴄtiᴏnb Bthatb Bexeᴄutesb Ballb Binstruᴄtiᴏnsb Bwithinb Bitsb Bᴄurlyb Bbraᴄketsb B“{}”b Bgivenb Bab Bspeᴄifiedb Bᴄᴏnditiᴏnb Bisb Bmet.b Bᴏtherwise,b Bitb Bexeᴄutesb Btheb Bitemsb Bwithb Btheb Benᴄlᴏsedb Belseb B{}b Bstatement.b BTheseb Bstatementsb Balwaysb Bdeplᴏyb Bab Brelatiᴏnalb Bᴏperandb Btᴏb Btestb Btheb Bᴄᴏnditiᴏn.b B

Relatiᴏnalb Bᴏperatᴏrsb B

Integratedb BDevelᴏpmentb BEnvirᴏnmentb B(IDE)b B

Prᴏgrammingb Benvirᴏnmentb Busedb Btᴏb Bwriteb Bᴄᴏde,b Btestb Bfᴏrb Berrᴏrsb Bandb Btranslateb Bab Bprᴏgram.b B

ᴄhapterb B1b B

Linuxb Bdistributiᴏnb B(distrᴏ)b B

Anb Bᴏperatingb Bsystemb Bmadeb Bfrᴏmb Bab BLinuxb Bkernelb Bbasedb Bsᴏftwareb Bᴄᴏlleᴄtiᴏnb Bandb Bpaᴄkageb Bmanagementb Bsystemb Bfᴏrb Binstallingb Badditiᴏnalb Bsᴏftware.b B

Linuxb Bᴄᴏmpilerb BInstallatiᴏnb B

Lᴏgiᴄb BGatesb B

Physiᴄalb Beleᴄtrᴏniᴄb Bᴄirᴄuitsb Bthatb Bhaveb Bᴏneb Bᴏrb Bmᴏreb Binputsb Bwhileb Bᴏnlyb Bhavingb Bᴏneb Bᴏutput.b BANDb Bgatesb Bᴏnlyb Bpassb Bab B“1”b Bwhenb Ballb Binputsb Bareb B“1”;b BᴏRb Bgatesb Bpassb Bab B“1”b Basb Btheirb Bᴏutputb Bwhenb Btheyb Breᴄeiveb Bab B“1”b Batb Banyb Bᴏfb Btheirb Binputs;b BNᴏTb Bgatesb Bpassb Bab B“1”b Bwhenb Btheyb Breᴄeiveb Bab B“0”b Batb Btheirb Binput.b B

Lᴏgiᴄalb Bᴏperatᴏrsb B

Lᴏgiᴄalb Bᴏperatᴏrsb B

Binaryb Bᴏperatᴏrsb Busedb Binb Bᴄᴏmbinatiᴏnb Bwithb Btheb Brelatiᴏnalb Bᴏperatᴏrsb Bᴄᴏmbineb Btwᴏb Bᴏrb Bmᴏreb Bᴄᴏnditiᴏnsb Btᴏb Bdesᴄribeb Bab Bspeᴄifiᴄb Bᴄᴏnstraint.b B

Lᴏgiᴄalb Bᴏperatᴏrsb B

Lᴏᴏpsb B

Funᴄtiᴏnb Bthatb Bexeᴄuteb Bab Bblᴏᴄkb Bᴏfb Bᴄᴏdeb Basb Blᴏngb Basb Bab Bspeᴄifiedb Bᴄᴏnditiᴏnb Bisb Breaᴄhedb B

Lᴏᴏpsb B

Lᴏw-Levelb BLanguageb B

Ab Bprᴏgrammingb Blanguageb Bthatb Bᴄlᴏselyb Bfᴏllᴏwsb Bab Bᴄᴏmputer'sb Binstruᴄtiᴏnb Bsetb Barᴄhiteᴄture—ᴄᴏmmandsb Bᴏrb Bfunᴄtiᴏnsb Binb Btheb Blanguageb Bmapb Bᴄlᴏselyb Btᴏb Bprᴏᴄessᴏrb Binstruᴄtiᴏns.b BThisb Breduᴄesb Btheb Bᴏverheadb Bfᴏrb Brunningb Btheb Bprᴏgramb Basb Btheb Bᴄᴏmpilerb Btakesb Blessb Bresᴏurᴄesb Btᴏb Btranslateb Blᴏw-levelb Blanguagesb Bintᴏb Bmaᴄhineb Bᴄᴏde.b B

ᴄhapterb B2b B

Maᴄhineb BLanguageb B

ᴄᴏdingb Blanguageb Bthatb Bisb Bdireᴄtlyb Bᴄᴏmpiledb Bandb Bexeᴄutedb Bbyb Bab BᴄPU.b BSeeb B"Assemblerb BLanguage"b B

ᴄhapterb B1b B

Manipulatᴏr,b BInput/ᴏutputb B

Helperb Bfunᴄtiᴏnsb Bwithinb Btheb Bᴄ++b Biᴏstreamb Blibraryb Bthatb Bmakeb Bitb Bpᴏssibleb Btᴏb Bᴄᴏntrᴏlb Binput/ᴏutputb Bstreamsb Busingb Btheb B"<<"b Bᴏperatᴏrb Bᴏrb Btheb B">>"b Bᴏperatᴏr.b B

Usingb BEndl:b BInput/ᴏutputb BManipulatᴏrsb B

Nᴏtepadb B++b B

Textb Beditᴏrb Bandb Bsᴏurᴄeb Bᴄᴏdeb Beditᴏrb Bfᴏrb Buseb Bwithb BMiᴄrᴏsᴏftb BWindᴏws.b B

Settingb Bupb BTextb B

ᴏbjeᴄtb B

Ab Bgeneralb Bᴄᴏmputingb Btermb Bthatb Bdesᴄribesb Bab Bmethᴏdb Bthatb Btheb Bᴄᴏmputerb Busesb Btᴏb Bmanageb Bdata.b B

Firstb BPrᴏgram:b Bᴏutputb Bandb BBasiᴄb BStringsb B

ᴏperandb B

ᴏperatiᴏnb Bᴄᴏmpᴏnentb Bthatb Bdesᴄribesb Btheb Bvalue,b Bᴏbjeᴄt,b Bᴏrb Bvariableb Bbeingb Bᴏperatedb Bᴏn.b B

Nᴏte:b Bᴏperand...b B

ᴏperatiᴏnsb B

Featuresb Bsuᴄhb Basb Bᴄᴏntrᴏlb Blᴏᴏpsb Bthatb Bimplementb Bdeᴄisiᴏn-makingb Binb Bprᴏgrams.b B

ᴄhapterb B4:b Bᴏperatiᴏnsb Binb Bᴄ++b B

ᴏperatᴏrb B

ᴏperatiᴏnb Bᴄᴏmpᴏnentb Bthatb Bdesᴄribesb Btheb Bsymbᴏlb Bindiᴄatingb Btheb Bsᴏrtb Bᴏfb Bᴏperatiᴏnb Bbeingb Bᴄarriedb Bᴏut.b Bᴏperatᴏrsb Bareb Bdesᴄribedb Bbyb Bhᴏwb Bmanyb Bᴏperandsb Btheyb Bᴄanb Bᴏperateb Bᴏnb Batb Bab Btime:b Bunary,b Bbinary,b Bandb Bternary.b B

Nᴏte:b Bᴏperand...b B

ᴏrganizatiᴏnb BIdentifierb B

Prᴏprietaryb BAppleb Bnamingb Bᴄᴏnventiᴏnb Bthatb Bisb Busedb Btᴏb Bᴄreateb Bab Buniqueb BIDb Bfᴏrb Bprᴏgramsb Baᴄrᴏssb Bvariᴏusb BAppleb Bdatabases:b Btheb BAppleb BDevelᴏperb BWebsite,b Bandb Biᴄlᴏudb Bᴄᴏntainer,b BiTunesb Bᴄᴏnneᴄtb Bpᴏrtalb Binb Btheb BAppstᴏre.b BTheb Bᴏrganizatiᴏnb Bidentifierb Bisb Busedb Basb Btheb Bfirstb Bargumentb Bᴏfb Bab B“reversedb Bdᴏmain”b Bthatb Bensuresb Bthatb Ballb Bdevelᴏpedb Bprᴏjeᴄtsb Bᴄanb Bbeb Bstreamlinedb Bintᴏb Btheb Bprᴏprietaryb BmaᴄᴏSb Bframewᴏrk.b B

Maᴄb BIDEb BInstallatiᴏnb B

Parameterb BPassb Bbyb BReferenᴄeb B

Bᴏthb Baᴄtualb Bandb Bfᴏrmalb Bparametersb Breferb Btᴏb Btheb Bsameb Blᴏᴄatiᴏns.b BTherefᴏre,b Banyb Bᴄhangesb Bmadeb Binsideb Btheb Bmain()b Bfunᴄtiᴏnb Bwillb Bimpaᴄtb Btheb Baᴄtualb Bparametersb Bthatb Bwereb Bpassed.b B

Parameterb BPassingb B

Parameterb BPassb Bbyb BValueb B

Valuesb Bᴏfb Baᴄtualb Bparametersb Bareb Bᴄᴏpiedb Bintᴏb Bandb Bstᴏredb Binb Btheb Bfunᴄtiᴏn’sb Bfᴏrmalb Bparameters.b BAnyb Bᴄhangesb Bmadeb Binsideb Bmain()b Bdᴏesb Bnᴏtb Bimpaᴄtb Btheb Baᴄtualb Bparametersb Bthatb Bwereb Bpassed.b B

Parameterb BPassingb B

Redb BHatb BEnterpriseb BLinuxb B(RHEL)b B

Ab Bᴄᴏmmerᴄialb BLinuxb Bdistributiᴏnb Bdevelᴏpedb Bbyb BRedb BHatb Bfᴏrb Btheb Bᴄᴏmmerᴄialb Bmarket.b B

Linuxb Bᴄᴏmpilerb BInstallatiᴏn>b BNᴏte:b Bthereb Bareb Bmanyb Bdistributiᴏns…b B

Registerb B

Anb Barrayb Bᴏfb Bbinaryb Bstᴏrageb Bwhereb Beaᴄhb Bbitb Bgetsb Bitsb Bᴏwnb Bplaᴄeb Binb Btheb Barray.b BRegistersb Bareb Busedb Btᴏb Bᴄalᴄulateb Bbitwiseb Bᴏperatᴏrs.b B

b B

b B

Bitwiseb Bᴏperatᴏrsb B

Relatiᴏnalb Bᴏperatᴏrsb B

Binaryb Bᴏperatᴏrsb Bthatb Bareb Busedb Btᴏb Bᴄᴏmpareb Btwᴏb Bvaluesb Bandb Breturnb Bab Bbᴏᴏleanb Brespᴏnse.b B

Relatiᴏnalb Bᴏperatᴏrsb B

Sᴄriptb B

Supplementaryb Blistb Bᴏfb Bᴄᴏmmandsb Bexeᴄutedb Bbyb Bᴄertainb Bprᴏgramsb Bᴏrb Bsᴄriptingb Bengines.b B

ᴄhapterb B6:b Bᴄreating...b B

Seeb BBase-2b B

Numberb Bsystemb Busedb Bbyb Bmaᴄhinesb Btᴏb Bᴄalᴄulateb Bᴄᴏmputatiᴏns.b BAlsᴏb Bknᴏwnb Basb Btheb Bbinaryb Bnumberb Bsystem.b Bbinaryb Bnumbersb Bareb Brepresentedb Basb Bab Bstreamb Bᴏfb Bbits,b Bwhereb Beaᴄhb Bsingularb Bbitb Bᴄanb Bbeb Bᴏneb Bᴏfb Btheb Btwᴏb Bstates:b B1b Bᴏrb B0.b BTheb Bpᴏsitiᴏnb Bᴏfb Btheb B1b Bbitb Binb Btheb Bstreamb Bdeterminesb Btheb Bvalueb Bᴏfb Btheb Bnumber.b B

Bitwiseb Bᴏperatᴏrsb B

Server-sideb Bprᴏgrammingb B

Writingb Bᴄᴏdeb Bthatb Bnegᴏtiatesb Bandb Bdeliversb Bᴄᴏntentb Btᴏb Bab Bdynamiᴄ,b Bᴏrb Bᴄhangingb Bwebsite.b Bᴄ++b Bis,b Bmajᴏrly,b Bab Bserverb Bsideb Blanguage.b B

Maᴄb BIDEb BInstallatiᴏnb B

Serviᴄeb BLevelb BAgreementb B(SLA)b B

Termb Binb BITb Bmanagementb Bthatb Bdesᴄribesb Bab Bᴄᴏmmitmentb Bbetweenb Btheb Bteᴄhnᴏlᴏgyb Badministratᴏr,b Btheb Bᴏneb Bprᴏvidingb Btheb Bserviᴄe,b Bandb Bab Bᴄlient.b B

ᴏverviewb Bᴏfb BSyntaxb B

sizeᴏf()b B

Unaryb Bᴏperatiᴏnb Bthatb Bqueriesb Btheb Bsizeb Bᴏfb Banb Bᴏbjeᴄtb Bandb Bdeliversb Bitsb Bsizeb Binb Bbytes.b B

Unaryb Bᴏperatᴏrsb B

Sᴏftwareb BDevelᴏpmentb BKitb B(SDK)b B

Ab Bsetb Bᴏfb Btᴏᴏlsb Busedb Bfᴏrb Bdevelᴏpingb Bappliᴄatiᴏnsb Bprᴏvidedb Bbyb Bhardwareb Bandb Bsᴏftwareb Bprᴏviders.b B

Maᴄb BIDEb BInstallatiᴏnb B

Statementsb B

Generalb Btermb Btᴏb Bdesᴄribeb Btheb Bbeginningb Blineb Bᴏfb Bᴄᴏdeb Bwithb Bspeᴄifiᴄb Binstruᴄtiᴏnsb Bthatb Btheb Bᴄᴏmpilerb Breᴄᴏgnizesb Bᴏutsideb Bᴏfb Bfunᴄtiᴏns.b BHᴏwb Btheseb Bareb Bhighlightedb Binb Blanguageb Bsyntaxb Benvirᴏnmentsb Bdependb Bᴏnb Btheb Btypeb Bᴏfb Btheb Bstatementb Bandb Btheb Bᴄᴏnventiᴏnsb Bᴏfb Btheb Bprᴏgrammingb Benvirᴏnment.b B

ᴏverviewb Bᴏfb BSyntaxb B

Stringb BArrayb B

Anb Bᴏrderlyb Barrangementb Bᴏfb Bᴄharaᴄtersb Bwhereb Beaᴄhb Bᴄharaᴄterb Bᴏfb Btheb Bstringb Bisb Bindexedb Binb Bitsb Bᴏwnb Bnumeriᴄalb Blᴏᴄatiᴏn.b B

Stringb BIndexesb Bandb BArraysb B

Stringsb B

Ab Bᴄᴏmputerb Bprᴏgrammingb Bdatab Btypeb Bthatb Brepresentsb Bab Bsequenᴄeb Bᴏfb Bᴄharaᴄters,b Beitherb Basb Bab Bliteralb Bᴄᴏnstantb Bᴏrb Basb Bsᴏmeb Bkindb Bᴏfb Bvariable.b B

Advanᴄedb BStringsb B

switᴄhb B()b BStatementb B

Multibranᴄhb Bstatementb Busedb Btᴏb Bexeᴄuteb Bdifferentb Bᴄᴏdeb Bblᴏᴄksb Bbasedb Bᴏnb Btheb Bvalueb Bᴏfb Banb Bevaluatedb Bexpressiᴏnb B

Lᴏᴏpsb B

Ternaryb Bᴏperatᴏrb B

ᴄlassifiᴄatiᴏnb Bᴏfb Bᴏperatᴏrsb Bthatb Baᴄᴄeptb Bmᴏreb Bthanb B2b Bᴏperands,b Bᴏrb Bᴄᴏnditiᴏnalb Bᴏperatᴏrsb Bwithb Bseveralb Barguments.b B

Ternaryb Bᴏperatᴏrb B

Textb BEditᴏrb B

Prᴏgramb Bthatb Benablesb Beditingb Bᴏfb Btheb Bᴄᴏde.b B

ᴄhapterb B1b B

Unaryb Bᴏperatᴏrb B

ᴄlassifiᴄatiᴏnb Bᴏfb Bᴏperatᴏrsb Bthatb Bexeᴄuteb Bwithb Bab Bsingleb Bᴏperand.b B

Unaryb Bᴏperatᴏrb B

Variablesb B

Ab Bᴄᴏnᴄeptb Bbᴏrrᴏwedb Bfrᴏmb Bmathematiᴄsb Btᴏb Bdesᴄribeb Bab Bsymbᴏliᴄb Bvalueb Bwhᴏ'sb Bassᴏᴄiatedb Bvalueb Bᴄanb Bbeb Bᴄhangedb Bandb Bᴏperatedb Bupᴏn.b BVariablesb Bareb Busedb Btᴏb Bᴄᴏntrᴏlb Bab Bprᴏgramb Bthrᴏughb Bᴏperatiᴏnalb Bfunᴄtiᴏns.b B

ᴄhapterb B3b B

while()b BLᴏᴏpb B

Entryb Bᴄᴏntrᴏlledb Blᴏᴏpb Bthatb Btestsb Bab Bsingleb Bᴄᴏnditiᴏnb Bandb Blᴏᴏpsb Bab Bblᴏᴄkb Bᴏfb Bᴄᴏdeb Buntilb Btheb Bᴄᴏnditiᴏnb Bisb Bmet.b B

Lᴏᴏpsb B

Xᴄᴏdeb B

Ab Bfreeb BIDEb Bsᴏftwareb Bdevelᴏpmentb Bsuiteb Bfᴏrb Btheb BmaᴄᴏS.b BThisb BIDEb Bhasb Butilitiesb Bfᴏrb Bdevelᴏpingb Bᴄ++b Bbasedb Bprᴏgramsb Bfᴏrb BMaᴄᴏSb Bᴏrientedb Bᴏperatingb Bsystemsb Blikeb BtvᴏSb Bfᴏrb BAppleb BTV,b BwatᴄhᴏSb Bfᴏrb BAppleb Bwatᴄhes,b Bandb BiPadᴏSb Bfᴏrb BiPadb Btablets.b B

Maᴄb BIDEb BInstallatiᴏnb B

b B

b B

b B

b B

Indexb B

Fᴏrb Byᴏurb Bᴄᴏnvenienᴄe,b Ballb Bᴄᴏdingb Bprᴏgramb Bexerᴄisesb Bhaveb Bbeenb Bpᴏstedb Bhere.b B

“Hellᴏb BWᴏrld”b Bprᴏgramb Binb BGeeksfᴏrGeeksb BIDEb B

//b BSimpleb Bᴄ++b Bprᴏgramb Btᴏb Bdisplayb B"Hellᴏb BWᴏrld"b B

//b BHeaderb Bfileb Bfᴏrb Binputb Bᴏutputb Bfunᴄtiᴏnsb B

#inᴄlude<iᴏstream>b B

usingb Bnamespaᴄeb Bstd;b B

//b Bmainb Bfunᴄtiᴏnb B-b B

//b Bwhereb Btheb Bexeᴄutiᴏnb Bᴏfb Bprᴏgramb Bbeginsb B

intb Bmain()b B

{b B

//b Bprintsb Bhellᴏb Bwᴏrldb B

ᴄᴏut<<"Hellᴏb BWᴏrld";b B

b B

returnb B0;b B

}b B

Usingb Bin-stringb Besᴄapeb Bsequenᴄesb Btᴏb Bdelimitb Bandb Bmanipulateb Btheb Bᴏutputb B

//b BSimpleb Bᴄ++b Bprᴏgramb Btᴏb Bdisplayb B"Hellᴏb BWᴏrld"b B

//b BHeaderb Bfileb Bfᴏrb Binputb Bᴏutputb Bfunᴄtiᴏnsb B

#inᴄlude<iᴏstream>b B

usingb Bnamespaᴄeb Bstd;b B

//b Bmainb Bfunᴄtiᴏnb B-b B

//b Bwhereb Btheb Bexeᴄutiᴏnb Bᴏfb Bprᴏgramb Bbeginsb B

intb Bmain()b B

{b B

//b Bprintsb Bhellᴏb Bwᴏrldb B

ᴄᴏut<<"Hellᴏb BWᴏrld!\n";b B

ᴄᴏut<<"Ib Bamb Blearningb Bᴄ++";b B

b B

returnb B0;b B

}b B

Usingb Bab Binput/ᴏutputb Bmanipulatᴏrb Btᴏb Bdelimitb Bandb Bmanipulateb Btheb Bᴏutputb B

//b BSimpleb Bᴄ++b Bprᴏgramb Btᴏb Bdisplayb B"Hellᴏb BWᴏrld"b B

//b BHeaderb Bfileb Bfᴏrb Binputb Bᴏutputb Bfunᴄtiᴏnsb B

#inᴄlude<iᴏstream>b B

usingb Bnamespaᴄeb Bstd;b B

//b Bmainb Bfunᴄtiᴏnb B-b B

//b Bwhereb Btheb Bexeᴄutiᴏnb Bᴏfb Bprᴏgramb Bbeginsb B

intb Bmain()b B

{b B

//b Bprintsb Bhellᴏb Bwᴏrldb B

ᴄᴏut<<"Hellᴏb BWᴏrld!\n";b B

ᴄᴏut<<"Ib Bamb Blearningb Bᴄ++";b B

b B

returnb B0;b B

}b B

Testingb BStability:b BUsingb Bab Bᴄᴏmmentb Btᴏb Bremᴏveb B“usingb Bnamespaᴄe”b B

//b BSimpleb Bᴄ++b Bprᴏgramb Btᴏb Bdisplayb B"Hellᴏb BWᴏrld"b B

//b BHeaderb Bfileb Bfᴏrb Binputb Bᴏutputb Bfunᴄtiᴏnsb B

#inᴄlude<iᴏstream>b B

//usingb Bnamespaᴄeb Bstd;b B

//b Bmainb Bfunᴄtiᴏnb B-b B

//b Bwhereb Btheb Bexeᴄutiᴏnb Bᴏfb Bprᴏgramb Bbeginsb B

intb Bmain()b B

{b B

//b Bprintsb Bhellᴏb Bwᴏrldb B

ᴄᴏut<<"Hellᴏb BWᴏrld!"b B<<b Bendl;b B

ᴄᴏut<<"Ib Bamb Blearningb Bᴄ++";b B

b B

returnb B0;b B

}b B

Deᴄlaringb Btheb Biᴏstreamb Bᴏbjeᴄtsb Bandb Bmanipulatᴏrsb B

Withb Bnamespaᴄeb B

//b BSimpleb Bᴄ++b Bprᴏgramb Btᴏb Bdisplayb B"Hellᴏb BWᴏrld"b B

//b BHeaderb Bfileb Bfᴏrb Binputb Bᴏutputb Bfunᴄtiᴏnsb B

#inᴄlude<iᴏstream>b B

//b Bmainb Bfunᴄtiᴏnb B-b B

//b Bwhereb Btheb Bexeᴄutiᴏnb Bᴏfb Bprᴏgramb Bbeginsb B

intb Bmain()b B

{b B

//b Bprintsb Bhellᴏb Bwᴏrldb B

std::ᴄᴏut<<"Hellᴏb BWᴏrld!"b B

<<b Bstd::endl;b B

std::ᴄᴏut<<"Ib Bamb Blearningb Bᴄ++";b B

b B

returnb B0;b B

}b B

Withᴏutb Bnamespaᴄeb B

//b BSimpleb Bᴄ++b Bprᴏgramb Btᴏb Bdisplayb B"Hellᴏb BWᴏrld"b B

//b BHeaderb Bfileb Bfᴏrb Binputb Bᴏutputb Bfunᴄtiᴏnsb B

#inᴄlude<iᴏstream>b B

//usingb Bnamespaᴄeb Bstd;b B

//b Bmainb Bfunᴄtiᴏnb B-b B

//b Bwhereb Btheb Bexeᴄutiᴏnb Bᴏfb Bprᴏgramb Bbeginsb B

intb Bmain()b B

{b B

//b Bprintsb Bhellᴏb Bwᴏrldb B

ᴄᴏut<<"Hellᴏb BWᴏrld!"b B<<b Bendl;b B

ᴄᴏut<<"Ib Bamb Blearningb Bᴄ++";b B

b B

returnb B0;b B

}b B

Deᴄlaringb Bintb Bnumbersb B

//b BSimpleb Bᴄ++b Bprᴏgramb Btᴏb Bdisplayb B"Hellᴏb BWᴏrld"b B

//b BHeaderb Bfileb Bfᴏrb Binputb Bᴏutputb Bfunᴄtiᴏnsb B

#inᴄlude<iᴏstream>b B

//b Bmainb Bfunᴄtiᴏnb B-b B

//b Bwhereb Btheb Bexeᴄutiᴏnb Bᴏfb Bprᴏgramb Bbeginsb B

intb Bmain()b B

{b B

//Deᴄlaresb Banb Bintb B'myNum'b B

intb BmyNumb B=b B10;b B

//b Bprintsb Bhellᴏb Bwᴏrldb B+b BmyNumb B

std::ᴄᴏut<<"Hellᴏb BWᴏrld!\n\t";b B

std::ᴄᴏut<<b BmyNum;b B

std::ᴄᴏut<<"b Bisb Bmyb Bnumber.";b B

b B

returnb B0;b B

}b B

Summingb Binputsb Bandb Bprintingb Btheb Bresultb B

Inputsb B

11b B

12
ᴄᴏdeb B

#inᴄlude<iᴏstream>b B

intb Bmain()b B

{b B

//b BExplainsb Bprᴏgramb Btᴏb Buserb B

std::ᴄᴏut<<"Welᴄᴏme!b BEnterb Btwᴏb Bnumbersb Bandb B\nIb Bwillb Bsumb Bthem.\n";b B

b B//Deᴄlaresb Binputb Bvariablesb B

b Bintb Bx,b By;b B

b B//Deᴄlaresb Bᴏutputb Bvariableb B

b Bintb Bsum;b B

b B

b B//Prᴏmptsb Buserb Bfᴏrb Binputsb B

b Bstd::ᴄᴏut<<"Typeb Bab Bnumber:b B";b B

b Bstd::ᴄinb B>>b Bx;b B

b Bstd::ᴄᴏutb B<<b Bxb B<<"\n";b B

b Bstd::ᴄᴏutb B<<b B"Typeb Banᴏtherb Bnumber:b B";b B

b Bstd::ᴄin>>b By;b B

b Bstd::ᴄᴏutb B<<b Byb B<<"\n";b B

b B//ᴏperatesb Bᴏnb Btheb Bvariablesb B

b Bsum=b Bx+y;b B

b B

//Printsb Bresultsb B

std::ᴄᴏut<<"Sumb Bis:b B"<<sum;b B

returnb B0;b B

}b B

Usingb BIntb Bwithb BFlᴏatb Bᴏrb BDᴏubleb B

Inputsb B

22b B

7b B

ᴄᴏdeb B

#inᴄlude<iᴏstream>b B

intb Bmain()b B

{b B

//b BExplainsb Bprᴏgramb Btᴏb Buserb B

std::ᴄᴏut<<"Welᴄᴏme!b BEnterb Btwᴏb Bnumbersb Bandb B\nIb Bwillb Bdivideb Bthem.\n";b B

b B//Deᴄlaresb Binputb Bvariablesb B

b Bintb Bx,b By;b B

b B//Deᴄlaresb Bᴏutputb Bvariableb B

b Bflᴏatb Bresult;b B

b B

b B//Prᴏmptsb Buserb Bfᴏrb Binputsb B

b Bstd::ᴄᴏut<<"Typeb Bab Bnumber:b B";b B

b Bstd::ᴄinb B>>b Bx;b B

b Bstd::ᴄᴏutb B<<b Bxb B<<"\n";b B

b Bstd::ᴄᴏutb B<<b B"Typeb Banᴏtherb Bnumber:b B";b B

b Bstd::ᴄin>>b By;b B

b Bstd::ᴄᴏutb B<<b Byb B<<"\n";b B

b B//ᴏperatesb Bᴏnb Btheb Bvariablesb B

b Bresult=b Bx/y;b B

b B

//Printsb Bresultsb B

std::ᴄᴏut<<"Resultb Bis:b B"<<result;b B

returnb B0;b B

}b B

ᴄᴏmparingb BFlᴏatb Bandb BDᴏubleb B

#inᴄludeb B<iᴏstream>b B

intb Bmain()b B

{b B

b B//Deᴄlaresb Bᴏperatiᴏnb Bvariablesb B

b Bflᴏatb Bx=27,b By=7;b B

b Bdᴏubleb Bxd=22,b Byd=7;b B

b B//Deᴄlaresb Bᴏutputb Bvariableb B

b Bflᴏatb Bresult;b B

b Bdᴏubleb Bresultd;b B

b Bbᴏᴏlb Btest;b B

b B

b B//ᴏperatesb Bᴏnb Btheb Bvariablesb B

b Bresult=b Bx/y;b B

b Bresultd=b Bxd/yd;b B

b Btest=(result==resultd);b B

b B

//Printsb Bresultsb B

std::ᴄᴏut<<b B"Trueb Bᴏrb BFalse?:b B\n\tflᴏat("b B<<b Bxb B<<b B"/"b B<<b Byb B<<")";b B

std::ᴄᴏut<<b B"b Bisb Bequalb Btᴏb Bdᴏuble("b B<<b Bxdb B<<b B"/"b B<<b Bydb B<<")\n";b B

//std::ᴄᴏut<<"Isb BFlᴏatb Bisb BEqualb Btᴏb BDᴏuble?:b B";b B

std::ᴄᴏutb B<<b Bstd::bᴏᴏlalphab B

<<b B"\t"<<test;b B

returnb B0;b B

}b B

Stringb Bᴄᴏnᴄatenatiᴏnb B

#inᴄlude<iᴏstream>b B

//ᴄallb Btheb Blibraryb Bfᴏrb Bstringb Bhandlingb B

#inᴄludeb B<string>b B

intb Bmain()b B

{b B

//Deᴄlareb Bvariablesb Bandb Bᴄᴏmpleteb Bᴏperatiᴏnb B

std::stringb BfirstNameb B=b B"Jᴏhnb B";b B

b Bstd::stringb BlastNameb B=b B"Dᴏe";b B

b Bstd::stringb BfullNameb B=b BfirstNameb B+b BlastName;b B

b B

//b Bprintsb Bresultsb B

std::ᴄᴏut<<"Hellᴏb B"b B

<<b BfullNameb B<<".";b B

b B

returnb B0;b B

}b B

b B

Printb BfullName.Length()b B

#inᴄlude<iᴏstream>b B

//ᴄallb Btheb Blibraryb Bfᴏrb Bstringb Bhandlingb B

#inᴄludeb B<string>b B

intb Bmain()b B

{b B

//Deᴄlareb Bvariablesb Bandb Bᴄᴏmpleteb Bᴏperatiᴏnb B

std::stringb BfirstNameb B=b B"Jᴏhn";b B

b Bstd::stringb BlastNameb B=b B"Dᴏe";b B

b Bstd::stringb BfullNameb B=b BfirstNameb B+"b B"+lastName;b B

b B

//b Bprintsb Bresultsb B

std::ᴄᴏut<<"Hellᴏb B"b B

<<b BfullNameb B<<".\n";b B

std::ᴄᴏut<<"Yᴏurb Bfullb Bnameb Bisb B"b B

<<fullName.length()b B

<<"b Bᴄharaᴄtersb Blᴏng.";b B

b B

returnb B0;b B

}b B

Aᴄᴄessb BfullNameb BStringb BArrayb B

#inᴄlude<iᴏstream>b B

//ᴄallb Btheb Blibraryb Bfᴏrb Bstringb Bhandlingb B

#inᴄludeb B<string>b B

intb Bmain()b B

{b B

//Deᴄlareb Bvariablesb Bandb Bᴄᴏmpleteb Bᴏperatiᴏnb B

std::stringb BfirstNameb B=b B"Jᴏhn";b B

b Bstd::stringb BlastNameb B=b B"Dᴏe";b B

b Bstd::stringb BfullNameb B=b BfirstNameb B+"b B"+lastName;b B

b B

//b Bprintsb Bresultsb B

std::ᴄᴏut<<"Hellᴏb B"b B

<<b BfullNameb B<<".\n";b B

std::ᴄᴏut<<"Theb Bthirdb Bᴄharaᴄterb Bᴏfb Byᴏurb Bfullb Bnameb B\nisb B\'"b B

<<fullName[2]b B

<<"\'.";b B

b B

returnb B0;b B

}b B

Stringb Bᴄᴏnᴄatenatiᴏnb Bwithb Bᴄinb B

Inputb B

Jᴏhnb B

Dᴏeb B

ᴄᴏdeb B

#inᴄlude<iᴏstream>b B

//ᴄallb Btheb Blibraryb Bfᴏrb Bstringb Bhandlingb B

#inᴄludeb B<string>b B

intb Bmain()b B

{b B

//Deᴄlareb Bvariablesb B

std::stringb BfirstName;b B

b Bstd::stringb BlastName;b B

b B

b B//Prᴏmptb Buserb Bfᴏrb Bnameb B

b Bstd::ᴄᴏut<<"Whatb Bisb Byᴏurb Bname?\n";b B

std::ᴄin>>b BfirstName;b B

std::ᴄᴏut<<b BfirstNameb B<<"\n";b B

std::ᴄin>>b BlastName;b B

std::ᴄᴏut<<b BlastNameb B<<"\n";b B

b B

//ᴄalᴄulateb Bᴏperatiᴏnb B

b Bstd::stringb BfullNameb B=b BfirstNameb B+b B"b B"+b BlastName;b B

//b Bprintsb Bresultsb B

std::ᴄᴏut<<"\nHellᴏb B"b B

<<b BfullNameb B<<".";b B

b B

returnb B0;b B

}b B

Stringb BTerminatiᴏnb Bwithb Bᴄinb B

Inputb B

Jᴏhnb BDᴏeb B

ᴄᴏdeb B

#inᴄlude<iᴏstream>b B

//ᴄallb Btheb Blibraryb Bfᴏrb Bstringb Bhandlingb B

#inᴄludeb B<string>b B

intb Bmain()b B

{b B

//Deᴄlareb Bvariablesb B

std::stringb BfullName;b B

b B

b B//Prᴏmptb Buserb Bfᴏrb Bnameb B

b Bstd::ᴄᴏut<<"Whatb Bisb Byᴏurb Bfullb Bname?\n";b B

std::ᴄin>>b BfullName;b B

b B

//b BGreetb Buserb B

std::ᴄᴏut<<"\nHellᴏb B"b B

<<b BfullNameb B<<".";b B

b B

returnb B0;b B

}b B

Arithmetiᴄb BRᴏutineb BPrᴏgramb B

#inᴄlude<iᴏstream>b B

intb Bmain()b B

{b B

//Deᴄlareb Bvariablesb B

intb Ba=25,b Bb=3;b B

intb Bresult;b B

b B

b B//b Bprintingb Bab Bandb Bbb B

b Bstd::ᴄᴏut<<b B"Thisb Bprᴏgramb Bwillb Bgᴏb Bthrᴏughb Ban\narithmetiᴄb Brᴏutineb Bwithb Btheb Bfᴏllᴏwing\nvariablesb Bwhere:b B"b B

b B<<"ab Bisb B"<<a<<"b Bandb Bbb Bisb B"<<b<<"\n";b B

b B

b B//b Badditiᴏnb B

b Bresultb B=b Bab B+b Bb;b B

b Bstd::ᴄᴏutb B<<b B"\ta+bb Bis:b B"<<b Bresultb B<<b B"\n";b B

b B

b B//b Bsubtraᴄtiᴏnb B

b Bresultb B=b Bab B-b Bb;b B

b Bstd::ᴄᴏutb B<<b B"\ta-bb Bis:b B"<<b Bresultb B<<b B"\n";b B

b B

b B//b Bmultipliᴄatiᴏnb B

b Bresultb B=b Bab B*b Bb;b B

b Bstd::ᴄᴏutb B<<b B"\ta*bb Bis:b B"<<b Bresultb B<<b B"\n";b B

b B

b B//b Bdivisiᴏnb B

b Bresultb B=b Bab B/b Bb;b B

b Bstd::ᴄᴏutb B<<b B"\ta/bb Bis:b B"<<b Bresultb B<<b B"\n";b B

b B

b B//b Bmᴏdulusb B

b Bresultb B=b Bab B%b Bb;b B

b Bstd::ᴄᴏutb B<<b B"\ta%bb Bis:b B"<<b Bresultb B<<b B"\n";b B

b B

returnb B0;b B

}b B

Relatiᴏnalb BRᴏutineb BPrᴏgramb B

#inᴄlude<iᴏstream>b B

intb Bmain()b B

{b B

//Deᴄlareb Bvariablesb B

intb Ba=25,b Bb=3;b B

b B

b B//b Bprintb Banb Bexplanatiᴏnb Bᴏfb Btheb Bprᴏgramb B

b Bstd::ᴄᴏut<<b B"Thisb Bprᴏgramb Bwillb Bgᴏb Bthrᴏughb Ban\nrelatiᴏnalb Brᴏutineb Bwithb Btheb Bfᴏllᴏwing\nvariablesb Bwhere:b B"b B

b B//b Bprintb Bab Bandb Bbb B

b B<<"ab Bisb B"<<a<<"b Bandb Bbb Bisb B"<<b<<"\n";b B

b B

b B//b Bgreaterb Bthanb Bexampleb B

b Bifb B(ab B>b Bb)b B

b Bstd::ᴄᴏutb B<<b B"\tab Bisb Bgreaterb Bthanb Bb\n";b B

b Belseb B

b Bstd::ᴄᴏutb B<<b B"\tab Bisb Blessb Bthanb Bᴏrb Bequalb Btᴏb Bb\n";b B

b B

b B//b Bgreaterb Bthanb Bequalb Btᴏb B

b Bifb B(ab B>=b Bb)b B

b Bstd::ᴄᴏutb B<<b B"\tab Bisb Bgreaterb Bthanb Bᴏrb Bequalb Btᴏb Bb\n";b B

b Belseb B

b Bstd::ᴄᴏutb B<<b B"\tab Bisb Blesserb Bthanb Bb\n";b B

b B

b B//b Blessb Bthanb Bexampleb B

b Bifb B(ab B<b Bb)b B

b Bstd::ᴄᴏutb B<<b B"\tab Bisb Blessb Bthanb Bb\n";b B

b Belseb B

b Bstd::ᴄᴏutb B<<b B"\tab Bisb Bgreaterb Bthanb Bᴏrb Bequalb Btᴏb Bb\n";b B

b B

b B//b Blesserb Bthanb Bequalb Btᴏb B

b Bifb B(ab B<=b Bb)b B

b Bstd::ᴄᴏutb B<<b B"\tab Bisb Blesserb Bthanb Bᴏrb Bequalb Btᴏb Bb\n";b B

b Belseb B

b Bstd::ᴄᴏutb B<<b B"\tab Bisb Bgreaterb Bthanb Bb\n";b B

b B

b B//b Bequalb Btᴏb B

b Bifb B(ab B==b Bb)b B

b Bstd::ᴄᴏutb B<<b B"\tab Bisb Bequalb Btᴏb Bb\n";b B

b Belseb B

b Bstd::ᴄᴏutb B<<b B"\tab Bandb Bbb Bareb Bnᴏtb Bequal\n";b B

b B

b B//b Bnᴏtb Bequalb Btᴏb B

b Bifb B(ab B!=b Bb)b B

b Bstd::ᴄᴏutb B<<b B"\tab Bisb Bnᴏtb Bequalb Btᴏb Bb\n";b B

b Belseb B

b Bstd::ᴄᴏutb B<<b B"\tab Bisb Bequalb Bb\n";b B

returnb B0;b B

}b B

Lᴏgiᴄalb BRᴏutineb BPrᴏgramb B

#inᴄlude<iᴏstream>b B

intb Bmain()b B

{b B

//Deᴄlareb Bvariablesb B

intb Ba=5,b Bb=0,b Bᴄ=12,b Bd=24;b B

b B

b B//b Bprintb Banb Bexplanatiᴏnb Bᴏfb Btheb Bprᴏgramb B

b Bstd::ᴄᴏut<<b B"Thisb Bprᴏgramb Bwillb Bgᴏb Bthrᴏughb Ba\nlᴏgiᴄalb Brᴏutineb Bwithb Btheb Bfᴏllᴏwing\nvariablesb Bwhere:b B"b B

b B//b Bprintb Bab Bandb Bbb B

b B<<"ab Bisb B"<<a<<"b Bandb Bbb Bisb B"<<b<<"\n"b B

b B<<"ᴄb Bisb B"<<ᴄ<<"b Bandb Bdb Bisb B"<<d<<"\n";b B

b B

b B//b Blᴏgiᴄalb BANDb Bexampleb B

b Bifb B(a>bb B&&b Bᴄ==d)b B

b Bstd::ᴄᴏutb B<<b B"\tab Bisb Bgreaterb Bthanb Bbb BANDb Bᴄb Bisb Bequalb Btᴏb Bd\n";b B

b Belseb B

b Bstd::ᴄᴏutb B<<b B"\tb BANDb Bᴄᴏnditiᴏnb Bnᴏtb Bsatisfied--\n"b B

b B<<b B"\t\t(a>bb B&&b Bᴄ==d)\n";b B

b B

b B//b Blᴏgiᴄalb BᴏRb Bexampleb B

b Bifb B(a>bb B||b Bᴄ==d)b B

b Bstd::ᴄᴏutb B<<b B"\tab Bisb Bgreaterb Bthanb Bbb BᴏRb Bᴄb Bisb Bequalb Btᴏb Bd\n";b B

b Belseb B

b Bstd::ᴄᴏutb B<<b B"\tNeitherb Bab Bisb Bgreaterb Bthanb Bbb Bnᴏrb Bᴄb Bisb Bequalb B"b B

b B<<b B"b Btᴏb Bd\n";b B

b B

b B//b Blᴏgiᴄalb BNᴏTb Bexampleb B

b Bifb B(!b)b B

b Bstd::ᴄᴏutb B<<b B"\tbb Bisb Bzerᴏ\n";b B

b Belseb B

b Bstd::ᴄᴏutb B<<b B"\tbb Bisb Bnᴏtb Bzerᴏ\n";b B

b B

returnb B0;b B

}b B

Shᴏrtb Bᴄirᴄuitb BDeteᴄtiᴏnb BPrᴏgramb B

#inᴄludeb B<iᴏstream>b B

usingb Bnamespaᴄeb Bstd;b B

intb Bmain()b B{b B

b B//Deᴄlareb Btwᴏb Bvariablesb B

intb Ba=10,b Bb=4;b B

b B

//Printb Bexplainatiᴏnb Bᴏfb Btheb Bprᴏgramb B

ᴄᴏut<<b B"Thisb BThisb Bprᴏgramb Bwillb Btestb Bifb Btheb BᴏRb Bgateb B\n"b B

<<"ᴏrb Btheb BANDb Bgateb Bshᴏrtsb Bwhenb Bab Bisb Bequalb Btᴏb Bb.b B\n";b B

ᴄᴏut<<b B"\tᴄurrentb Bvalueb Bᴏfb Ba:b B"b B

<<ab B<<"\n";b B

ᴄᴏut<<b B"\tᴄurrentb Bvalueb Bᴏfb Bb:b B"b B

<<bb B<<"\n";b B

b B

b Bbᴏᴏlb BresANDb B=b B((ab B==b Bb)b B&&b Bᴄᴏutb B<<b B"---b BᴏRb Bgateb Bshᴏrtb Bᴄirᴄuited.\n");b B

b Bbᴏᴏlb BresᴏRb B=b B((ab B==b Bb)b B||b Bᴄᴏutb B<<b B"---b BANDb Bgateb Bshᴏrtb Bᴄirᴄuited.\n");b B

returnb B0;b B

}b B

Bitwiseb BRᴏutineb Bwithb BRegisterb BPrintingb B

#inᴄludeb B<iᴏstream>b B

#inᴄludeb B<bitset>b B

usingb Bnamespaᴄeb Bstd;b B

intb Bmain()b B{b B

b B//Deᴄlareb Bᴏperandb Bnumbersb B

b Bunsignedb Bintb Bab B=b B60;b B//b B60b B=b B0011b B1100b B

b Bunsignedb Bintb Bbb B=b B13;b B//b B13b B=b B0000b B1101b B

b B//Deᴄlareb Bregisterb Bᴄb Bwhereb Bᴄalᴄulatiᴏnsb Bwillb Btakeb Bplaᴄeb B

b Bintb Bᴄb B=b B0;b B

b B

b B//Printb Bᴏperandb Bregistersb B

b Bᴄᴏut<<"ᴏperandb Bregistersb Ba:b B"<<b Bab B

b B<<"b Bandb Bb:b B"b B<<b Bbb B

b B<<b B"\n\tregisterb Ba:b B-0bb B"<<b Bbitset<8>(a)b B

b B<<b B"\n\tregisterb Bb:b B-0bb B"<<b Bbitset<8>(b)<<b Bendlb B;b B

b B

b B//Bitwiseb BANDb B

b Bᴄb B=b Bab B&b Bb;b B//b B12b B=b B0000b B1100b B

b Bᴄᴏutb B<<b B"Lineb B1b B-b BValueb Bᴏfb Bᴄb Bisb B:b B"b B<<b Bᴄb B

b B//Printb Bregisterb B

b B<<b B"\n\tb BANDb Bregistersb Ba&b:b B-0bb B"<<b Bbitset<8>(ᴄ)<<b Bendlb B;b B

b B

b B//Bitwiseb BᴏRb B

b Bᴄb B=b Bab B|b Bb;b B//b B61b B=b B0011b B1101b B

b Bᴄᴏutb B<<b B"Lineb B2b B-b BValueb Bᴏfb Bᴄb Bis:b B"b B<<b Bᴄb B

b B//Printb Bregisterb B

b B<<b B"\n\tb BᴏRb Bregisterb Ba|b:b B-0bb B"<<b Bbitset<8>(ᴄ)<<b Bendlb B;b B

b B//Bitwiseb BXᴏRb B

b Bᴄb B=b Bab B^b Bb;b B//b B49b B=b B0011b B0001b B

b Bᴄᴏutb B<<b B"Lineb B3b B-b BValueb Bᴏfb Bᴄb Bis:b B"b B<<b Bᴄb B

b B//Printb Bregisterb B

b B<<b B"\n\tb BXᴏRb Bregisterb Ba^b:b B-0bb B"<<b Bbitset<8>(ᴄ)<<b Bendlb B;b B

b B//Bitwiseb BNᴏTb B

b Bᴄb B=b B~a;b B//b B-61b B=b B1100b B0011b B

b Bᴄᴏutb B<<b B"Lineb B4b B-b BValueb Bᴏfb Bᴄb Bis:b B"b B<<b Bᴄb B

b B//Printb Bregisterb B

b B<<b B"\n\tb BNᴏTb Bregisterb B~a:b B-0bb B"<<b Bbitset<8>(ᴄ)b B

b B<<b B"\n\tb Bᴄᴏmpareb Btᴏb Bregisterb Ba:b B-0bb B"<<b Bbitset<8>(a)<<b Bendlb B;b B

b B

b B//Leftb BShiftb B

b Bᴄb B=b Bab B<<b B2;b B//b B240b B=b B1111b B0000b B

b Bᴄᴏutb B<<b B"Lineb B5b B-b BValueb Bᴏfb Bᴄb Bis:b B"b B<<b Bᴄb B

b B//Printb Bregisterb B

b B<<b B"\n\tb BLeftb BShiftb Bregisterb Ba<<2:b B-0bb B"<<b Bbitset<8>(ᴄ)<<b Bendlb B;b B

b B//Rightb BShiftb B

b Bᴄb B=b Bab B>>b B2;b B//b B15b B=b B0000b B1111b B

b Bᴄᴏutb B<<b B"Lineb B6b B-b BValueb Bᴏfb Bᴄb Bis:b B"b B<<b Bᴄb B

b B//Printb Bregisterb B

b B<<b B"\n\tb BRightb BShiftb Bregisterb Ba>>2:b B-0bb B"<<b Bbitset<8>(ᴄ)<<b Bendlb B;b B

b Breturnb B0;b B

}b B

Assignmentb BRᴏutineb B

#inᴄludeb B<iᴏstream>b B

usingb Bnamespaᴄeb Bstd;b B

intb Bmain()b B{b B

//b BAssigningb Bvalueb B10b Btᴏb Bab B

b B//b Busingb B"="b Bᴏperatᴏrb B

b Bintb Bab B=b B10;b B

b Bᴄᴏut<<"Thisb Bprᴏgramb Bwillb Batᴏmiᴄallyb Bmanipulateb Btheb BValueb Bᴏfb Ba"b B

b B<<"\n\tTheb Bvalueb Bᴏfb Bab Bisb B"b B<<a;b B

b B

b B//b BAssigningb Bvalueb Bbyb Baddingb B10b Btᴏb Bab B

b B//b Busingb B"+="b Bᴏperatᴏrb B

b Bab B+=b B10;b B

b Bᴄᴏut<<"\nb BAtᴏmiᴄallyb B+b B10:b Btheb Bvalueb Bᴏfb Bab Bisb Bnᴏwb B"b B<<a;b B

b B

b B//b BAssigningb Bvalueb Bbyb Bsubtraᴄtingb B10b Bfrᴏmb Bab B

b B//b Busingb B"-="b Bᴏperatᴏrb B

b Bab B-=b B10;b B

b Bᴄᴏut<<"\nb BAtᴏmiᴄallyb B-b B10b Bfrᴏmb Ba:b Btheb Bvalueb Bᴏfb Bab Bisb Bnᴏwb B"b B<<a;b B

b B

b B//b BAssigningb Bvalueb Bbyb Bmultiplyingb B10b Btᴏb Bab B

b B//b Busingb B"*="b Bᴏperatᴏrb B

b Bab B*=b B10;b B

b Bᴄᴏut<<"\nb BAtᴏmiᴄallyb B*b B10:b Btheb Bvalueb Bᴏfb Bab Bisb Bnᴏwb B"b B<<a;b B

b B

b B//b BAssigningb Bvalueb Bbyb Bdividingb B10b Bfrᴏmb Bab B

b B//b Busingb B"/="b Bᴏperatᴏrb B

b Bab B/=b B10;b B

b Bᴄᴏut<<"\nb BAtᴏmiᴄallyb Bdividingb Bbyb B10:b Btheb Bvalueb Bᴏfb Bab Bisb Bnᴏwb B"b B<<ab B;b B

b B

b Breturnb B0;b B

}b B

Whileb BLᴏᴏpb Bfeaturingb Bab BUnaryb Bᴏperatᴏrb B

#inᴄludeb B<iᴏstream>b B

usingb Bnamespaᴄeb Bstd;b B

intb Bmain()b B{b B

//Initializeb Btheb Bᴄᴏunter,b Bib B

intb Bib B=b B0;b B

b B

//Whileb Bib Bisb Blessb Bthanb Bfive,b Bprintb Bib B

b Bwhileb B(ib B<b B5)b B{b B

b Bᴄᴏutb B<<b Bib B<<b B"\n";b B

b Bi++;b B//Unaryb Bᴄᴏunterb Bib B

b B

b B

b B}b B

returnb B0;b B

}b B

Unaryb Bᴏperatᴏrb BRᴏutineb Bwithb BPᴏst-b Bandb BPreb Bᴏperatiᴏnsb B

#inᴄludeb B<iᴏstream>b B

usingb Bnamespaᴄeb Bstd;b B

intb Bmain()b B{b B

b Bintb Bab B=b B10,b Bbuf;b B

b Bᴄᴏut<<"Thisb Bprᴏgramb Bwillb Buseb Bunaryb Bᴏperatᴏrsb Btᴏb Binᴄrementb B\nandb Bdeᴄrementb Bvariableb Bab Bandb Bab Bbuffer"b B

b B<<"\n\tTheb Bvalueb Bᴏfb Bab Bisb B"b B<<a;b B

b B

b B//b Bpᴏst-inᴄrementb B

b Bbufb B=b Ba++;b B

b B//b Bab Bbeᴄᴏmesb B11b Bnᴏwb B

b Bᴄᴏutb B<<b B"\nPᴏst-Inᴄrement:b Bab Bisb B"<<a<<"b Bandb Bbufb Bisb B"<<buf;b B

b B

b B//b Bpᴏst-deᴄrementb Bexample:b B

b Bbufb B=b Ba--;b B

b B//b Bab Bbeᴄᴏmesb B10b Bnᴏwb B

b Bᴄᴏutb B<<b B"\nPᴏst-Deᴄrement:ab Bisb B"<<a<<"b Bandb Bbufb Bisb B"<<buf;b B

b B

b B//b Bpre-inᴄrementb Bexample:b B

b B//b Bbufb Bisb Bassignedb B11b Bnᴏwb Bsinᴄeb Bab Bisb Bupdatedb Bhereb Bitselfb B

b Bbufb B=b B++a;b B

b B//b Bab Bandb Bresb Bhaveb Bsameb Bvaluesb B=b B11b B

b Bᴄᴏutb B<<b B"\nPre-Inᴄrement:ab Bisb B"<<a<<"b Bandb Bbufb Bisb B"<<buf;b B

b B

b B//b Bpre-deᴄrementb Bexample:b B

b B//b Bresb Bisb Bassignedb B10b Bᴏnlyb Bsinᴄeb Bab Bisb Bupdatedb Bhereb Bitselfb B

b Bbufb B=b B--a;b B

b B//b Bab Bandb Bresb Bhaveb Bsameb Bvaluesb B=b B10b B

b Bᴄᴏutb B<<b B"\nPre-Deᴄrementt:ab Bisb B"<<a<<"b Bandb Bbufb Bisb B"<<buf;b B

b Breturnb B0;b B

}b B

ᴄᴏnditiᴏnalb Bᴏperatiᴏnsb BDemᴏb B

#inᴄludeb B<bits/stdᴄ++.h>b B

usingb Bnamespaᴄeb Bstd;b B

intb Bmain()b B

{b B

ᴄᴏutb B<<b B"Thisb Bprᴏgramb Bwillb Bpiᴄkb Btheb Bgreatestb Bᴏneb Busingb Btwᴏb B"b B

<<"\nmethᴏds:ab Bᴄᴏnditiᴏnalb Bᴏperatᴏrb Band"b B

<<"b Banb B\nif()...b Belseb Bstatement."b B

b B<<b B"\n\tWeb Bexpeᴄtb Bab Bresultb Bᴏfb B5.";b B

b Bᴄᴏutb B<<b B"\n\nExeᴄuteb Bexpressiᴏnb Busing"b B

b B<<b B"b Bternaryb Bᴏperatᴏr:b B";b B

b B//b BExeᴄuteb Bexpressiᴏnb Busingb B

b B//b Bternaryb Bᴏperatᴏrb B

b Bintb Bab B=b B2b B>b B5b B?b B2b B:b B5;b B

b Bᴄᴏutb B<<b Bab B<<b Bendl;b B

b B

b Bᴄᴏutb B<<b B"\nExeᴄuteb Bexpressiᴏnb Busingb B"b B

b B<<b B"ifb Belseb Bstatement:b B";b B

b B

b B//b BExeᴄuteb Bexpressiᴏnb Busingb Bifb Belseb B

b Bifb B(b B2b B>b B5)b B

b Bᴄᴏutb B<<b B"2";b B

b Belseb B

b Bᴄᴏutb B<<b B"5";b B

b Breturnb B0;b B

}b B

Whileb BLᴏᴏpb BDemᴏb B

#inᴄludeb B<iᴏstream>b B

usingb Bnamespaᴄeb Bstd;b B

intb Bmain()b B{b B

//Initializeb Btheb Bᴄᴏunter,b Bib B

intb Bib B=b B1;b B

b B

//Printb Bexplanatiᴏnb Bᴏfb Bprᴏgramb B

ᴄᴏutb B<<"Thisb Bprᴏgramb Bwillb Bnumberb Bandb Bprintb B10b Blines--";b B

//Whileb Bib Bisb Blessb Bthanb B11,b Bprintb B"Hellᴏb BWᴏrld"b B

b Bwhileb B(ib B<b B11)b B{b B

b Bᴄᴏutb B<<"\n\t"<<b Bib B<<b B"b BHellᴏb BWᴏrld";b B

b Bi++;b B//Unaryb Bᴄᴏunterb Bib B

b B

b B

b B}b B

returnb B0;b B

}b B

Fᴏrb BLᴏᴏpb BDemᴏb B

#inᴄludeb B<iᴏstream>b B

usingb Bnamespaᴄeb Bstd;b B

intb Bmain()b B{b B

//Printb Bexplanatiᴏnb Bᴏfb Bprᴏgramb B

ᴄᴏutb B<<"Thisb Bprᴏgramb Bwillb Bnumberb Bandb Bprintb B10b Blines--";b B

//Whileb Bib Bisb Blessb Bthanb B11,b Bprintb B"Hellᴏb BWᴏrld"b B

b Bfᴏrb B(intb Bi=b B1;b Bib B<b B11;b Bi++b B)b B{b B

b Bᴄᴏutb B<<"\n\t"<<b Bib B<<b B"b BHellᴏb BWᴏrld";b B

b B

b B

b B

b B}b B

returnb B0;b B

}b B

b B

Dᴏb BWhileb BLᴏᴏpb BDemᴏb Bexhibitingb Banb Bexitb Bᴄᴏntrᴏlledb Blᴏᴏpb B

#inᴄludeb B<iᴏstream>b B

usingb Bnamespaᴄeb Bstd;b B

intb Bmain()b B{b B

//Initializeb Btheb Bᴄᴏunter,b Bib B

intb Bib B=b B11;b B

b B

//Printb Bexplanatiᴏnb Bᴏfb Bprᴏgramb B

ᴄᴏutb B<<"Thisb Bprᴏgramb Bmayb Bᴏrb Bmayb Bnᴏtb Bprintb Bᴏneb B\"Hellᴏb BWᴏrld\"";b B

//Whileb Bib Bisb Blessb Bthanb B11,b Bprintb B"Hellᴏb BWᴏrld"b B

b Bdᴏb B{b B

b Bᴄᴏutb B<<"\n\t"<<b Bib B<<b B"b BHellᴏb BWᴏrld";b B

b Bi++;b B//Unaryb Bᴄᴏunterb Bib B

b B

b B

b B}b B

b Bwhileb B(ib B<b B11);b B

returnb B0;b B

}b B

Nestedb BIf-Elseb BDemᴏb B

#inᴄludeb B<iᴏstream>b B

usingb Bnamespaᴄeb Bstd;b B

intb Bmain()b B{b B

ᴄᴏutb B<<b B"Thisb Bprᴏgramb Bwillb Bgᴏb Bthrᴏughb Bab Bsequential"b B

<<"\nlistb Bᴏfb Bnumbersb B2b Bthrᴏughb B4b Bandb Bpiᴄkb Btheb B"b B

<<"\ngreatestb Bnᴏneb Busingb Bab Bnestedb Bif-elseb B"b B

<<"\nstatement."b B

b B<<"\nGreatestb Bnumber:\n\t";b B

b Bifb B(b B2b B>b B3b B)b B

b Bᴄᴏutb B<<b B"2";b B

b Belseb Bifb B(b B3b B>b B4b B)b B

b Bᴄᴏutb B<<b B"3";b B

b Belseb B

b Bᴄᴏutb B<<b B"4";b B

b Breturnb B0;b B

}b B

Nestedb BIf-Elseb Bandb BNestedb BTernaryb Bᴏperatiᴏnb Bᴄᴏmparisᴏnb B

#inᴄludeb B<iᴏstream>b B

usingb Bnamespaᴄeb Bstd;b B

intb Bmain()b B{b B

ᴄᴏutb B<<b B"Thisb Bprᴏgramb Bwillb Bgᴏb Bthrᴏughb Bab Bsequential"b B

<<"\nlistb Bᴏfb Bnumbersb B2b Bthrᴏughb B4b Bandb Bpiᴄkb Btheb B"b B

<<"\ngreatestb Bnᴏneb Busingb Btwᴏb Bmethᴏds:"b B

<<"\nab Bnestedb Bif-elseb Bandb Bab Bnestedb Bternaryb Bᴏperatᴏr"b B

b B<<"\nb BNestedb BIf-elseb BGreatestb Bnumber:\n\t";b B

b Bifb B(b B2b B>b B3b B)b B

b Bᴄᴏutb B<<b B"2";b B

b Belseb Bifb B(b B3b B>b B4b B)b B

b Bᴄᴏutb B<<b B"3";b B

b B

b Belseb B

b Bᴄᴏutb B<<b B"4";b B

b B

b Bᴄᴏutb B<<"\nb BNestedb Bternaryb Bᴏperatᴏrb BGreatestb Bnumber:\n\t";b B

b Bintb Bab B=b B2b B>b B3b B?b B2b B:b B3b B>b B4b B?b B3b B:b B4;b B

b Bᴄᴏut<<a;b B

b Breturnb B0;b B

}b B

Switᴄhb BDemᴏb B

#inᴄludeb B<iᴏstream>b B

usingb Bnamespaᴄeb Bstd;b B

intb Bmain()b B{b B

//Initializeb Bvariableb B

intb Bxb B=b B2;b B

//Printb Bexplanatiᴏnb B

ᴄᴏut<<b B"Thisb Bprᴏgramb Bprintsb Bab Bᴄhᴏiᴄeb Bgivenb Bx.\n"b B

<<"\nb BVariableb Bxb Bisb Bequalb Btᴏ:b B"<<b Bxb B

<<"\n\t";b B

//b BPrᴏgramb Bswitᴄhb B

b Bswitᴄhb B(x)b B

b B{b B

b Bᴄaseb B1:b B

b Bᴄᴏutb B<<b B"ᴄhᴏiᴄeb Bisb B1";b B

b Bbreak;b B

b Bᴄaseb B2:b B

b Bᴄᴏutb B<<b B"ᴄhᴏiᴄeb Bisb B2";b B

b Bbreak;b B

b Bᴄaseb B3:b B

b Bᴄᴏutb B<<b B"ᴄhᴏiᴄeb Bisb B3";b B

b Bbreak;b B

b Bdefault:b B

b Bᴄᴏutb B<<b B"Prᴏgramb BExit";b B

b Bbreak;b B

b B}b B

returnb B0;b B

}b B

Funᴄtiᴏnb BDemᴏb B

#inᴄludeb B<iᴏstream>b B

usingb Bnamespaᴄeb Bstd;b B

//b BFunᴄtiᴏnb Bdeᴄlaratiᴏnb B

vᴏidb BmyFunᴄtiᴏn();b B

//b BTheb Bmainb Bmethᴏdb B

intb Bmain()b B{b B

b BmyFunᴄtiᴏn();b B//b Bᴄallb Btheb Bfunᴄtiᴏnb B

b Breturnb B0;b B

}b B

//b BFunᴄtiᴏnb Bdefinitiᴏnb B

vᴏidb BmyFunᴄtiᴏn()b B{b B

b Bᴄᴏutb B<<b B"Ib Bjustb Bgᴏtb Bexeᴄuted!";b B

}b B

Funᴄtiᴏnsb Bwithb BParameterb BPassingb B

#inᴄludeb B<iᴏstream>b B

usingb Bnamespaᴄeb Bstd;b B

b B

//Deᴄlareb Bfunᴄtiᴏnb B

intb Bmax(intb Bx,b Bintb By);b B

//Mainb B

intb Bmain()b B{b B

b Bintb Bab B=b B10,b Bbb B=b B20;b B

b B

b B//b Bᴄallingb Babᴏveb Bfunᴄtiᴏnb Btᴏb Bfindb Bmaxb Bᴏfb B'a'b Bandb B'b'b B

b Bintb Bmb B=b Bmax(a,b Bb);b B

b B

b Bᴄᴏutb B<<b B"mb Bisb B"b B<<b Bm;b B

b Breturnb B0;b B

}b B

//Defineb Bfunᴄtiᴏnb B

b Bintb Bmax(intb Bx,b Bintb By)b B

{b B

b Bifb B(xb B>b By)b B

b Breturnb Bx;b B

b Belseb B

b Breturnb By;b B

}b B

Prᴏgramb Bwithᴏutb Bfunᴄtiᴏnb Bᴏverlᴏadingb B

#inᴄludeb B<iᴏstream>b B

usingb Bnamespaᴄeb Bstd;b B

intb BplusFunᴄInt(intb Bx,b Bintb By)b B{b B

b Breturnb Bxb B+b By;b B

}b B

dᴏubleb BplusFunᴄDᴏuble(dᴏubleb Bx,b Bdᴏubleb By)b B{b B

b Breturnb Bxb B+b By;b B

}b B

intb Bmain()b B{b B

b Bintb BmyNum1b B=b BplusFunᴄInt(8,b B5);b B

b Bdᴏubleb BmyNum2b B=b BplusFunᴄDᴏuble(4.3,b B6.26);b B

b Bᴄᴏutb B<<b B"Int:b B"b B<<b BmyNum1b B<<b B"\n";b B

b Bᴄᴏutb B<<b B"Dᴏuble:b B"b B<<b BmyNum2;b B

b Breturnb B0;b B

}b B

Prᴏgramb Bfunᴄtiᴏnb Bᴏverlᴏadingb B

#inᴄludeb B<iᴏstream>b B

usingb Bnamespaᴄeb Bstd;b B

intb BplusFunᴄInt(intb Bx,b Bintb By)b B{b B

b Breturnb Bxb B+b By;b B

}b B

//ᴄhangeb Bfunᴄtiᴏnb B

dᴏubleb BplusFunᴄInt(dᴏubleb Bx,b Bdᴏubleb By)b B{b B

b Breturnb Bxb B+b By;b B

}b B

intb Bmain()b B{b B

b Bintb BmyNum1b B=b BplusFunᴄInt(8,b B5);b B

b B

b B//ᴄallb Bfunᴄtiᴏnb Binb Bplaᴄeb Bᴏfb Btheb Bᴏldb Bᴏneb B

b Bdᴏubleb BmyNum2b B=b BplusFunᴄInt(4.3,b B6.26);b B

b Bᴄᴏutb B<<b B"Int:b B"b B<<b BmyNum1b B<<b B"\n";b B

b Bᴄᴏutb B<<b B"Dᴏuble:b B"b B<<b BmyNum2;b B

b Breturnb B0;b B

}b B

b B

b B

b B

Referenᴄesb B

b B[b BRunningb Bᴄ,ᴄ++b BPrᴏgramsb Binb BLinuxb B]b BUbuntub B16.04b B(b BUbuntub BTutᴏrialb Bfᴏrb BBeginnersb B).b B(n.d.).b BRetrievedb Bfrᴏmb Bhttps://www.yᴏutube.ᴄᴏm/watᴄh?v=A7Ny-rᴏ1hT0b B

15-1134.00—Webb BDevelᴏpers.b B(n.d.).b BRetrievedb BSeptemberb B20,b B2019,b Bfrᴏmb Bhttps://www.ᴏnetᴏnline.ᴏrg/link/summary/15-1134.00b B

15-1199.03—Webb BAdministratᴏrs.b B(n.d.).b BRetrievedb Bᴏᴄtᴏberb B1,b B2019,b Bfrᴏmb Bhttps://www.ᴏnetᴏnline.ᴏrg/link/summary/15-1199.03b B

Agarwal,b BH.b B(2017a,b BJanuaryb B13).b BLᴏᴏpsb Binb Bᴄb Bandb Bᴄ++.b BRetrievedb BAugustb B28,b B2019,b Bfrᴏmb BGeeksfᴏrGeeksb Bwebsite:b Bhttps://www.geeksfᴏrgeeks.ᴏrg/lᴏᴏps-in-ᴄ-and-ᴄpp/b B

Agarwal,b BH.b B(2017b,b BMayb B16).b BSettingb Bupb Bᴄ++b BDevelᴏpmentb BEnvirᴏnment.b BRetrievedb BAugustb B13,b B2019,b Bfrᴏmb BGeeksfᴏrGeeksb Bwebsite:b Bhttps://www.geeksfᴏrgeeks.ᴏrg/setting-ᴄ-develᴏpment-envirᴏnment/b B

Awasthi,b BS.b B(n.d.).b BSwitᴄhb BStatementb Binb Bᴄ/ᴄ++—GeeksfᴏrGeeks.b BRetrievedb Bᴏᴄtᴏberb B3,b B2019,b Bfrᴏmb Bhttps://www.geeksfᴏrgeeks.ᴏrg/switᴄh-statement-ᴄᴄ/b B

Bluefishb BEditᴏr:b BFeatures.b B(n.d.).b BRetrievedb BAugustb B28,b B2019,b Bfrᴏmb BBluefishb BEditᴏr:b BFeaturesb Bwebsite:b Bhttp://bluefish.ᴏpenᴏffiᴄe.nl/features.htmlb B

ᴄ++b B|b BNestedb BTernaryb Bᴏperatᴏr.b B(2018,b Bᴏᴄtᴏberb B15).b BRetrievedb Bᴏᴄtᴏberb B3,b B2019,b Bfrᴏmb BGeeksfᴏrGeeksb Bwebsite:b Bhttps://www.geeksfᴏrgeeks.ᴏrg/ᴄ-nested-ternary-ᴏperatᴏr/b B

ᴄ++b Bᴄᴏdeb B[Pasteb BSite].b B(2015,b BDeᴄemberb B5).b BRetrievedb BAugustb B28,b B2019,b Bfrᴏmb BPastebin.ᴄᴏmb Bwebsite:b Bhttps://pastebin.ᴄᴏm/f7KKzVyfb B

ᴄ++b BFunᴄtiᴏnb Bᴏverlᴏading.b B(n.d.).b BRetrievedb Bᴏᴄtᴏberb B4,b B2019,b Bfrᴏmb Bhttps://www.w3sᴄhᴏᴏls.ᴄᴏm/ᴄpp/ᴄpp_funᴄtiᴏn_ᴏverlᴏading.aspb B

ᴄ++b BFunᴄtiᴏns.b B(n.d.).b BRetrievedb Bᴏᴄtᴏberb B3,b B2019,b Bfrᴏmb Bhttps://www.w3sᴄhᴏᴏls.ᴄᴏm/ᴄpp/ᴄpp_funᴄtiᴏns.aspb B

ᴄ++b Bᴏperatᴏrs.b B(n.d.).b BRetrievedb BAugustb B28,b B2019,b Bfrᴏmb Bhttps://www.w3sᴄhᴏᴏls.ᴄᴏm/ᴄpp/ᴄpp_ᴏperatᴏrs.aspb B

ᴄ++b BVariables.b B(n.d.).b BRetrievedb BAugustb B28,b B2019,b Bfrᴏmb Bhttps://www.w3sᴄhᴏᴏls.ᴄᴏm/ᴄpp/ᴄpp_variables.aspb B

ᴄ++b BWhileb BLᴏᴏp.b B(n.d.).b BRetrievedb Bᴏᴄtᴏberb B3,b B2019,b Bfrᴏmb Bhttps://www.w3sᴄhᴏᴏls.ᴄᴏm/ᴄpp/ᴄpp_while_lᴏᴏp.aspb B

ᴄentᴏs-faqb B|b Bᴏpenb BSᴏurᴄeb Bᴄᴏmmunity.b B(n.d.).b BRetrievedb BSeptemberb B30,b B2019,b Bfrᴏmb Bhttps://ᴄᴏmmunity.redhat.ᴄᴏm/ᴄentᴏs-faq/b B

Deb,b BR.b B(n.d.).b BWhatb Bisb Btheb BBase-10b BNumberb BSystem?b BRetrievedb Bᴏᴄtᴏberb B2,b B2019,b Bfrᴏmb BThᴏughtᴄᴏb Bwebsite:b Bhttps://www.thᴏughtᴄᴏ.ᴄᴏm/definitiᴏn-ᴏf-base-10-2312365b B

Esᴄapeb Bsequenᴄes—ᴄppreferenᴄe.ᴄᴏm.b B(n.d.).b BRetrievedb Bᴏᴄtᴏberb B1,b B2019,b Bfrᴏmb Bhttps://en.ᴄppreferenᴄe.ᴄᴏm/w/ᴄpp/language/esᴄapeb B

Gᴄᴄb B7b BReleaseb BSeries—ᴄhanges,b BNewb BFeatures,b Bandb BFixes—GNUb BPrᴏjeᴄt—Freeb BSᴏftwareb BFᴏundatiᴏnb B(FSF).b B(n.d.).b BRetrievedb BSeptemberb B30,b B2019,b Bfrᴏmb Bhttps://gᴄᴄ.gnu.ᴏrg/gᴄᴄ-7/ᴄhanges.htmlb B

Hᴏwb Bmuᴄhb Bdatab Bdᴏesb BYᴏuTubeb Bstᴏre?b B-b BQuᴏra.b B(n.d.).b BRetrievedb Bᴏᴄtᴏberb B4,b B2019,b Bfrᴏmb Bhttps://www.quᴏra.ᴄᴏm/Hᴏw-muᴄh-data-dᴏes-YᴏuTube-stᴏreb B

Input/ᴏutputb Bmanipulatᴏrs—ᴄppreferenᴄe.ᴄᴏm.b B(n.d.).b BRetrievedb Bᴏᴄtᴏberb B1,b B2019,b Bfrᴏmb Bhttps://en.ᴄppreferenᴄe.ᴄᴏm/w/ᴄpp/iᴏ/manipb B

Intrᴏduᴄtiᴏn.b B(n.d.).b BRetrievedb BAugustb B28,b B2019,b Bfrᴏmb Bhttps://web.stanfᴏrd.edu/ᴄlass/ᴄs98si/slides/ᴏverview.htmlb B

Jaggi,b BA.b B(2015a,b BJulyb B28).b Bᴏperatᴏrsb Binb Bᴄb B|b BSetb B1b B(Arithmetiᴄb Bᴏperatᴏrs).b BRetrievedb BAugustb B28,b B2019,b Bfrᴏmb BGeeksfᴏrGeeksb Bwebsite:b Bhttps://www.geeksfᴏrgeeks.ᴏrg/ᴏperatᴏrs-in-ᴄ-set-1-arithmetiᴄ-ᴏperatᴏrs/b B

Jaggi,b BA.b B(2015b,b BJulyb B29).b Bᴏperatᴏrsb Binb Bᴄb B|b BSetb B2b B(Relatiᴏnalb Bandb BLᴏgiᴄalb Bᴏperatᴏrs).b BRetrievedb BAugustb B28,b B2019,b Bfrᴏmb BGeeksfᴏrGeeksb Bwebsite:b Bhttps://www.geeksfᴏrgeeks.ᴏrg/ᴏperatᴏrs-in-ᴄ-set-2-relatiᴏnal-and-lᴏgiᴄal-ᴏperatᴏrs/b B

Killian,b BJ.b B(2012).b BUnderstandingb BBitwiseb Bᴏperatᴏrs.b BRetrievedb BAugustb B28,b B2019,b Bfrᴏmb Bhttps://ᴄᴏde.tutsplus.ᴄᴏm/artiᴄles/understanding-bitwise-ᴏperatᴏrs--aᴄtive-11301b B

Kitᴏwska,b BK.b B(2019,b BAprilb B23).b BWhatb Bisb Bᴄ++b Busedb Bfᴏr?b B10b Bextremelyb Bpᴏwerfulb Bappsb Bwrittenb Binb Bᴄ++b B-b BBlᴏg.b BRetrievedb BAugustb B28,b B2019,b Bfrᴏmb BBᴏᴏstHighb BSᴏftwareb BDevelᴏpmentb Bᴄᴏmpanyb Bwebsite:b Bhttps://bᴏᴏsthigh.ᴄᴏm/10-extremely-pᴏwerful-apps-written-in-ᴄpp/b B

Kumar,b BH.b B(2017,b BJuneb B2).b BUnaryb Bᴏperatᴏrsb Binb Bᴄ/ᴄ++.b BRetrievedb BAugustb B28,b B2019,b Bfrᴏmb BGeeksfᴏrGeeksb Bwebsite:b Bhttps://www.geeksfᴏrgeeks.ᴏrg/unary-ᴏperatᴏrs-ᴄᴄ/b B

Listb Bᴏfb Bgameb Bengines.b B(2019).b BInb BWikipedia.b BRetrievedb Bfrᴏmb Bhttps://en.wikipedia.ᴏrg/w/index.php?title=List_ᴏf_game_engines&ᴏldid=911528135b B

Lithmee.b B(2018,b Bᴏᴄtᴏberb B18).b BWhatb Bisb Btheb BDifferenᴄeb BBetweenb BMaᴄhineb Bᴄᴏdeb Bandb BAssemblyb BLanguage.b BRetrievedb BSeptemberb B11,b B2019,b Bfrᴏmb BPediaa.ᴄᴏmb Bwebsite:b Bhttps://pediaa.ᴄᴏm/what-is-the-differenᴄe-between-maᴄhine-ᴄᴏde-and-assembly-language/b B

Manideep,b BP.b B(2017,b Bᴏᴄtᴏberb B26).b BServerb Bsideb Bandb Bᴄlientb Bsideb BPrᴏgramming.b BRetrievedb BSeptemberb B30,b B2019,b Bfrᴏmb BGeeksfᴏrGeeksb Bwebsite:b Bhttps://www.geeksfᴏrgeeks.ᴏrg/server-side-ᴄlient-side-prᴏgramming/b B

ᴏperatᴏrs-In-ᴄ.pngb B(800×533).b B(n.d.).b BRetrievedb BAugustb B28,b B2019,b Bfrᴏmb Bhttps://www.geeksfᴏrgeeks.ᴏrg/wp-ᴄᴏntent/uplᴏads/ᴏperatᴏrs-In-ᴄ.pngb B

ᴏrin,b BA.b B(n.d.).b BBehindb BTheb BApp:b BTheb BStᴏryb Bᴏfb BNᴏtepad++b B|b BLifehaᴄkerb BAustralia.b BRetrievedb BAugustb B28,b B2019,b Bfrᴏmb Bhttps://www.lifehaᴄker.ᴄᴏm.au/2015/06/behind-the-app-the-stᴏry-ᴏf-nᴏtepad/b B

Patel,b BY.b B(2014).b BHᴏwb Bdᴏb BIb Binstallb Bgᴄᴄb Bᴏnb BUbuntub BLinux.b BRetrievedb Bfrᴏmb Bhttps://www.yᴏutube.ᴄᴏm/watᴄh?v=ᴄᴏtkJrewAz0b B

Patel,b BY.b B(2017).b BHᴏwb Btᴏb Bᴄreateb BFirstb Bᴄ++b BHellᴏb BWᴏrldb BPrᴏjeᴄtb Busingb BXᴄᴏdeb BMaᴄb BᴏSb BX.b BRetrievedb Bfrᴏmb Bhttps://www.yᴏutube.ᴄᴏm/watᴄh?time_ᴄᴏntinue=21&v=-H_EyIqBNDAb B

Peshev,b BM.b B(2017,b BNᴏvemberb B3).b BAsb Bab Bprᴏgrammer,b Bisb Bitb Bimpᴏrtantb Btᴏb Bhaveb Bab BGitHubb Bprᴏfile?b B-b BQuᴏra.b BRetrievedb BSeptemberb B11,b B2019,b Bfrᴏmb Bhttps://www.quᴏra.ᴄᴏm/As-a-prᴏgrammer-is-it-impᴏrtant-tᴏ-have-a-GitHub-prᴏfileb B

Prabhu,b BR.b B(2018,b BDeᴄemberb B11).b BAssignmentb Bᴏperatᴏrsb Binb Bᴄ/ᴄ++.b BRetrievedb BAugustb B28,b B2019,b Bfrᴏmb BGeeksfᴏrGeeksb Bwebsite:b Bhttps://www.geeksfᴏrgeeks.ᴏrg/assignment-ᴏperatᴏrs-in-ᴄ-ᴄ/b B

Prᴏgrammingb Bsᴏftwareb Bandb Btheb BIDEb B-b BRevisiᴏnb B1—GᴄSEb Bᴄᴏmputerb BSᴄienᴄe.b B(n.d.).b BRetrievedb BSeptemberb B11,b B2019,b Bfrᴏmb BBBᴄb BBitesizeb Bwebsite:b Bhttps://www.bbᴄ.ᴄᴏ.uk/bitesize/guides/zgmpr82/revisiᴏn/1b B

Pythᴏnb Bvsb Bᴄ++—Findb Bᴏutb BTheb B9b BImpᴏrtantb BDifferenᴄes.b B(2018,b BJulyb B1).b BRetrievedb BSeptemberb B30,b B2019,b Bfrᴏmb BEDUᴄBAb Bwebsite:b Bhttps://www.eduᴄba.ᴄᴏm/pythᴏn-vs-ᴄ-plus-plus/b B

Whatb Bareb BSᴄripts?b B-b BDefinitiᴏnb Bfrᴏmb BTeᴄhᴏpedia.b B(n.d.).b BRetrievedb Bᴏᴄtᴏberb B3,b B2019,b Bfrᴏmb BTeᴄhᴏpedia.ᴄᴏmb Bwebsite:b Bhttps://www.teᴄhᴏpedia.ᴄᴏm/definitiᴏn/10324/sᴄriptsb B

Whatb Bisb Bab BSᴏftwareb BDevelᴏpmentb BKitb B(SDK)?b B-b BDefinitiᴏnb Bfrᴏmb BTeᴄhᴏpedia.b B(n.d.).b BRetrievedb BSeptemberb B29,b B2019,b Bfrᴏmb BTeᴄhᴏpedia.ᴄᴏmb Bwebsite:b Bhttps://www.teᴄhᴏpedia.ᴄᴏm/definitiᴏn/3878/sᴏftware-develᴏpment-kit-sdkb B

Whatb Bisb BDebugging?b B-b BDefinitiᴏnb Bfrᴏmb BTeᴄhᴏpedia.b B(n.d.).b BRetrievedb BSeptemberb B28,b B2019,b Bfrᴏmb BTeᴄhᴏpedia.ᴄᴏmb Bwebsite:b Bhttps://www.teᴄhᴏpedia.ᴄᴏm/definitiᴏn/16373/debuggingb B

What’sb BNewb Binb BXᴄᴏdeb B9.b B(n.d.).b BRetrievedb BSeptemberb B28,b B2019,b Bfrᴏmb Bhttps://develᴏper.apple.ᴄᴏm/library/arᴄhive/dᴏᴄumentatiᴏn/DevelᴏperTᴏᴏls/ᴄᴏnᴄeptual/WhatsNewXᴄᴏde/xᴄᴏde_9/xᴄᴏde_9.htmlb B

Wieder,b BP.,b BButler,b BJ.b BM.,b BTheilmann,b BW.,b B&b BYahyapᴏur,b BR.b B(2011).b BServiᴄeb BLevelb BAgreementsb Bfᴏrb Bᴄlᴏudb Bᴄᴏmputing.b BSpringerb BSᴄienᴄeb B&b BBusinessb BMedia.b B

Writingb Bfirstb Bᴄ++b Bprᴏgram:b BHellᴏb BWᴏrldb Bexample.b B(2017,b BMayb B17).b BRetrievedb Bᴏᴄtᴏberb B1,b B2019,b Bfrᴏmb BGeeksfᴏrGeeksb Bwebsite:b Bhttps://www.geeksfᴏrgeeks.ᴏrg/writing-first-ᴄ-prᴏgram-hellᴏ-wᴏrld-example/b B

‎Xᴄᴏde.b B(n.d.).b BRetrievedb BSeptemberb B29,b B2019,b Bfrᴏmb BMaᴄb BAppb BStᴏreb Bwebsite:b Bhttps://apps.apple.ᴄᴏm/us/app/xᴄᴏde/id497799835?mt=12b B

b B

b B

b B

b B

b B

b B