SlideShare a Scribd company logo
Professional slides for your work and your learning
require a guide
require an update
Active tools in your new presentation:
- operations buttons;
- search commands;
- bracket avaible;
- active links to web.
Press F5 to continue.
version 1.2
>>
Practical basics on writing C++
Basic operations quick guide
Practical basics on writing C++
I/O and math operation symbols
libraries to include
heading and functions
1
#include <iostream> //proprocessor direcrive
using namespace std;
code for output
cout << "Hello word!n; //this istruction can be write as
//cout << "Hello word!" << endl;
Practical basics on writing C++
I/O and math operation symbols
libraries to include
heading and functions
2
#include <iostream> //proprocessor direcrive
using namespace std;
code for input
int number; //name of variable
cin >> number; //reading by system of variable
Practical basics on writing C++
I/O and math operation symbols
sum of two operators
+
- subtraction of two operators
division of two operators
/
* product of two operators
calculation of the change in a division between two operators
%
Practical basics on writing C++
I/O and math operation symbols
retention of a number in an element
=
== comparision of two elements
increment of 1
++
-- decrease of 1
Practical basics on writing C++
I/O and math operation symbols
member b of object a
a.b
*x pointed to by x
adress of x
&x
x->y member y of object pointed to by x
object pointed to by x
x[n]
Practical basics on writing C++
Mix input data with output messages
code from text editor
#include <iostream>
using namespace std;
int main () {
cout << “Enter a number.n”;
int number;
cin >> number;
cout << “You have endered the number “ << number << endl; //”number”;
return 0; //this istruction return the command to OS and exits from the program
}
result from terminal
Enter a number.
4
You have entered the number 4.
Practical basics on writing C++
Condition if…else
code from text editor
#include <iostream>
using namespace std;
int main () {
cout << “Enter a number.n”;
int number;
cin >> number;
if (number < 10) { //condition
cout << “The number entered is less than 10.n”; reutrn 0; }
else
cout << “The number entered is higher than 10.n”; return 0;
}
result from terminal
Enter a number.
7
The number entered is less than 10.
Enter a number.
25
The number entered is higher than 10.
This function can be used to
manage errors by user.
Practical basics on writing C++
Condition switch
code from text editor
#include <iostream>
using namespace std;
int main () {
cout << “Enter 1 to print a message, press 2 to exitn”;
int number_selection;
cin >> number_selection;
switch (number_selection) {
case 1:
cout << “Hi!n”;
return main ();
case 2:
return 0;
default:
cout << “Error! Please, press 1 or 2 keypass.n”;
return main ();
}
}
This function can be used to
project a menu, for example.
1
Practical basics on writing C++
Condition switch
result from terminal
Enter 1 to print a message, press 2 to exit.
1
Hi!
Enter 1 to print a message, press 2 to exit.
Enter 1 to print a message, press 2 to exit.
2
This function can be used to
project a menu, for example.
Enter 1 to print a message, press 2 to exit.
3
Error! Please, press 1 or 2 keypass.
Enter 1 to print a message, press 2 to exit.
2
Practical basics on writing C++
Cycles: for
code from text editor
#include <iostream>
using namespace std;
int main () {
for (int a = 10; a < 20; a = a+1)
{
cout << “Value: " << a << “.n”;
}
return 0;
}
result from terminal
Value: 10.
Value: 11.
Value: 12.
Value: 13.
Value: 14.
Value: 15.
Value: 16.
Value: 17.
Value: 18.
Value: 19.
Be careful to loops!
Practical basics on writing C++
Cycles: while
code from text editor
#include <iostream>
using namespace std;
int main () {
int n = 10; //initialisation
while (n>0) { cout << n << ", ";
--n;
}
cout << "liftoff!n";
}
result from terminal
10, 9, 8, 7, 6, 5, 4, 3, 2, 1, liftoff!
Be careful to loops!
Practical basics on writing C++
Cycles: do…while
code from text editor
//example of an echo machine
#include <iostream>
#include <string>
using namespace std;
int main () {
string str;
do {
cout << "Enter text. ";
getline (cin,str);
cout << "You entered the following sentence.n " << str << 'n';
}
while (str != "goodbye");
}
result from terminal
Enter text.
Hello!
You entered the following sentences.
Hello!
Be careful to loops!
do…while executes at least once
the operation, while while and
for could not execute that.
Practical basics on writing C++
Arrays and vectors: creations and operations
code from text editor
//declaration of array
int name_of_array[10]; //the array’s size is 10
for(int i=0; i < 14; i++) //initialisarion of array
{
cout << name_of_array[10] << endl; //array’s printing
}
1
Practical basics on writing C++
Arrays and vectors: creations and operations
another example
#include <iostream>
using namespace std;
int foo[] = {16, 2, 77, 40, 12071};
int n, result=0;
int main () {
for ( n=0; n<5; ++n) {
result += foo[n];
}
cout << result; return 0;
}
result from terminal
12206
2
Practical basics on writing C++
Classes
public class
#include <iostream>
using namespace std;
class rectangle {
int width, height;
public:
rectangle ();
rectangle (int,int);
int area (void) {
return (width * height);
}
};
rectangle::rectangle ()
{width = 5; height = 5;
}
rectangle::rectangle (int a, int b)
{width = a;
height = b;
}
int main () {r
rectangle rect(3,4);
rectangle rectb;
cout << “rect area: " << rect.area() << endl;
cout << "rectb area: " << rectb.area() << endl;
return 0;
}
By default, in C++ the programmer
insert private class type.
1
Practical basics on writing C++
Classes
output from bash
rect area: 12
rectb area: 25
2
Practical basics on writing C++
Compiling operation
command from bash
g++ <name_of_source_code>.cpp –o <name_of_executable>
Practical basics on writing C++
Run command
command from bash
./<name_of_executable>
Index
I/O and math operations symbols
Mix input data with output messages
Condition if…else
Compiling operation
Classes
Cycles: for
Cycles: while
Cycles: do…while
Arrays and vectors: creations and operations
Index
Run command
Get help for free!
marco.izzottialessandro@gmail.com
Priority avaible to anyone.
Marco A. Izzotti
Only for friends.
348 0530717
Avaible only for italians during days.

More Related Content

What's hot

Unit 1 of c++ first program
Unit 1 of c++ first programUnit 1 of c++ first program
Unit 1 of c++ first program
AKR Education
 
Lecture#9 Arrays in c++
Lecture#9 Arrays in c++Lecture#9 Arrays in c++
Lecture#9 Arrays in c++
NUST Stuff
 
C++ Programming - 11th Study
C++ Programming - 11th StudyC++ Programming - 11th Study
C++ Programming - 11th Study
Chris Ohk
 
please sir i want to comments of every code what i do in eachline . in this w...
please sir i want to comments of every code what i do in eachline . in this w...please sir i want to comments of every code what i do in eachline . in this w...
please sir i want to comments of every code what i do in eachline . in this w...
hwbloom27
 
c++ exp 1 Suraj...pdf
c++ exp 1 Suraj...pdfc++ exp 1 Suraj...pdf
c++ exp 1 Suraj...pdf
ayush616992
 
C#.net
C#.netC#.net
C#.net
vnboghani
 
How c program execute in c program
How c program execute in c program How c program execute in c program
How c program execute in c program
Rumman Ansari
 
First c program
First c programFirst c program
First c program
Komal Pardeshi
 
Python workshop session 6
Python workshop session 6Python workshop session 6
Python workshop session 6
Abdul Haseeb
 
C++ functions
C++ functionsC++ functions
C++ functions
Mayank Jain
 
UNIT-II CP DOC.docx
UNIT-II CP DOC.docxUNIT-II CP DOC.docx
UNIT-II CP DOC.docx
JavvajiVenkat
 
Programs of C++
Programs of C++Programs of C++
C++20 features
C++20 features C++20 features
C++20 features
LogeekNightUkraine
 
Computer Networks Lab File
Computer Networks Lab FileComputer Networks Lab File
Computer Networks Lab File
Kandarp Tiwari
 
project report in C++ programming and SQL
project report in C++ programming and SQLproject report in C++ programming and SQL
project report in C++ programming and SQL
vikram mahendra
 
Python programming workshop session 2
Python programming workshop session 2Python programming workshop session 2
Python programming workshop session 2
Abdul Haseeb
 
Chap 5 c++
Chap 5 c++Chap 5 c++
Solved Practice Problems For the C++ Exams
Solved Practice Problems For the C++ ExamsSolved Practice Problems For the C++ Exams
Solved Practice Problems For the C++ Exams
MuhammadTalha436
 

What's hot (20)

Unit 1 of c++ first program
Unit 1 of c++ first programUnit 1 of c++ first program
Unit 1 of c++ first program
 
Lecture#9 Arrays in c++
Lecture#9 Arrays in c++Lecture#9 Arrays in c++
Lecture#9 Arrays in c++
 
Functions
FunctionsFunctions
Functions
 
C++ Programming - 11th Study
C++ Programming - 11th StudyC++ Programming - 11th Study
C++ Programming - 11th Study
 
please sir i want to comments of every code what i do in eachline . in this w...
please sir i want to comments of every code what i do in eachline . in this w...please sir i want to comments of every code what i do in eachline . in this w...
please sir i want to comments of every code what i do in eachline . in this w...
 
c++ exp 1 Suraj...pdf
c++ exp 1 Suraj...pdfc++ exp 1 Suraj...pdf
c++ exp 1 Suraj...pdf
 
C#.net
C#.netC#.net
C#.net
 
How c program execute in c program
How c program execute in c program How c program execute in c program
How c program execute in c program
 
Output
OutputOutput
Output
 
First c program
First c programFirst c program
First c program
 
Python workshop session 6
Python workshop session 6Python workshop session 6
Python workshop session 6
 
C++ functions
C++ functionsC++ functions
C++ functions
 
UNIT-II CP DOC.docx
UNIT-II CP DOC.docxUNIT-II CP DOC.docx
UNIT-II CP DOC.docx
 
Programs of C++
Programs of C++Programs of C++
Programs of C++
 
C++20 features
C++20 features C++20 features
C++20 features
 
Computer Networks Lab File
Computer Networks Lab FileComputer Networks Lab File
Computer Networks Lab File
 
project report in C++ programming and SQL
project report in C++ programming and SQLproject report in C++ programming and SQL
project report in C++ programming and SQL
 
Python programming workshop session 2
Python programming workshop session 2Python programming workshop session 2
Python programming workshop session 2
 
Chap 5 c++
Chap 5 c++Chap 5 c++
Chap 5 c++
 
Solved Practice Problems For the C++ Exams
Solved Practice Problems For the C++ ExamsSolved Practice Problems For the C++ Exams
Solved Practice Problems For the C++ Exams
 

Viewers also liked

C++ practical lab
C++ practical labC++ practical lab
C++ practical lab
Bachagul Ghaljai
 
C++:Lab 2
 C++:Lab 2 C++:Lab 2
C++:Lab 2
سلمى شطا
 
C++ lab -4
C++ lab -4C++ lab -4
C++ lab -4
سلمى شطا
 
Practical C++ Generative Programming
Practical C++ Generative ProgrammingPractical C++ Generative Programming
Practical C++ Generative Programming
Schalk Cronjé
 
c++ lab manual
c++ lab manualc++ lab manual
c++ lab manual
Shrunkhala Wankhede
 
Lab manual of C++
Lab manual of C++Lab manual of C++
Lab manual of C++
thesaqib
 
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board ExamsC++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
hishamrizvi
 
12th CBSE Practical File
12th CBSE Practical File12th CBSE Practical File
12th CBSE Practical File
Ashwin Francis
 
C++ project on police station software
C++ project on police station softwareC++ project on police station software
C++ project on police station software
dharmenderlodhi021
 
Computer science project work
Computer science project workComputer science project work
Computer science project work
rahulchamp2345
 

Viewers also liked (10)

C++ practical lab
C++ practical labC++ practical lab
C++ practical lab
 
C++:Lab 2
 C++:Lab 2 C++:Lab 2
C++:Lab 2
 
C++ lab -4
C++ lab -4C++ lab -4
C++ lab -4
 
Practical C++ Generative Programming
Practical C++ Generative ProgrammingPractical C++ Generative Programming
Practical C++ Generative Programming
 
c++ lab manual
c++ lab manualc++ lab manual
c++ lab manual
 
Lab manual of C++
Lab manual of C++Lab manual of C++
Lab manual of C++
 
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board ExamsC++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
 
12th CBSE Practical File
12th CBSE Practical File12th CBSE Practical File
12th CBSE Practical File
 
C++ project on police station software
C++ project on police station softwareC++ project on police station software
C++ project on police station software
 
Computer science project work
Computer science project workComputer science project work
Computer science project work
 

Similar to Practical basics on c++

OOPS using C++
OOPS using C++OOPS using C++
OOPS using C++
cpjcollege
 
C++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWAREC++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWARE
UNIVERSITY OF ENGINEERING AND TECHNOLOGY TAXILA
 
Hello world! Intro to C++
Hello world! Intro to C++Hello world! Intro to C++
Hello world! Intro to C++
DSCIGDTUW
 
Introduction to cpp
Introduction to cppIntroduction to cpp
Introduction to cpp
Nilesh Dalvi
 
Oops presentation
Oops presentationOops presentation
Oops presentation
sushamaGavarskar1
 
Modify this code to use multiple threads with the same data1.Modif.pdf
Modify this code to use multiple threads with the same data1.Modif.pdfModify this code to use multiple threads with the same data1.Modif.pdf
Modify this code to use multiple threads with the same data1.Modif.pdf
mallik3000
 
C++ Functions.ppt
C++ Functions.pptC++ Functions.ppt
C++ Functions.ppt
kanaka vardhini
 
power point presentation on object oriented programming functions concepts
power point presentation on object oriented programming functions conceptspower point presentation on object oriented programming functions concepts
power point presentation on object oriented programming functions concepts
bhargavi804095
 
Fundamental of programming Fundamental of programming
Fundamental of programming Fundamental of programmingFundamental of programming Fundamental of programming
Fundamental of programming Fundamental of programming
LidetAdmassu
 
Lecture2.ppt
Lecture2.pptLecture2.ppt
Lecture2.ppt
TarekHemdan3
 
Object Oriented Technologies
Object Oriented TechnologiesObject Oriented Technologies
Object Oriented Technologies
Umesh Nikam
 
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyC++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
GrejoJoby1
 
C++ functions
C++ functionsC++ functions
C++ functions
Dawood Jutt
 
C++ functions
C++ functionsC++ functions
C++ functions
Dawood Jutt
 
C++ Functions.ppt
C++ Functions.pptC++ Functions.ppt
C++ Functions.ppt
WaheedAnwar20
 
Introduction to C++ lecture ************
Introduction to C++ lecture ************Introduction to C++ lecture ************
Introduction to C++ lecture ************
Emad Helal
 
cpp-streams.ppt,C++ is the top choice of many programmers for creating powerf...
cpp-streams.ppt,C++ is the top choice of many programmers for creating powerf...cpp-streams.ppt,C++ is the top choice of many programmers for creating powerf...
cpp-streams.ppt,C++ is the top choice of many programmers for creating powerf...
bhargavi804095
 
C++ L01-Variables
C++ L01-VariablesC++ L01-Variables
C++ L01-Variables
Mohammad Shaker
 

Similar to Practical basics on c++ (20)

OOPS using C++
OOPS using C++OOPS using C++
OOPS using C++
 
Fp201 unit2 1
Fp201 unit2 1Fp201 unit2 1
Fp201 unit2 1
 
C++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWAREC++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWARE
 
Hello world! Intro to C++
Hello world! Intro to C++Hello world! Intro to C++
Hello world! Intro to C++
 
Introduction to cpp
Introduction to cppIntroduction to cpp
Introduction to cpp
 
Oops presentation
Oops presentationOops presentation
Oops presentation
 
Modify this code to use multiple threads with the same data1.Modif.pdf
Modify this code to use multiple threads with the same data1.Modif.pdfModify this code to use multiple threads with the same data1.Modif.pdf
Modify this code to use multiple threads with the same data1.Modif.pdf
 
CP 04.pptx
CP 04.pptxCP 04.pptx
CP 04.pptx
 
C++ Functions.ppt
C++ Functions.pptC++ Functions.ppt
C++ Functions.ppt
 
power point presentation on object oriented programming functions concepts
power point presentation on object oriented programming functions conceptspower point presentation on object oriented programming functions concepts
power point presentation on object oriented programming functions concepts
 
Fundamental of programming Fundamental of programming
Fundamental of programming Fundamental of programmingFundamental of programming Fundamental of programming
Fundamental of programming Fundamental of programming
 
Lecture2.ppt
Lecture2.pptLecture2.ppt
Lecture2.ppt
 
Object Oriented Technologies
Object Oriented TechnologiesObject Oriented Technologies
Object Oriented Technologies
 
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyC++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
 
C++ functions
C++ functionsC++ functions
C++ functions
 
C++ functions
C++ functionsC++ functions
C++ functions
 
C++ Functions.ppt
C++ Functions.pptC++ Functions.ppt
C++ Functions.ppt
 
Introduction to C++ lecture ************
Introduction to C++ lecture ************Introduction to C++ lecture ************
Introduction to C++ lecture ************
 
cpp-streams.ppt,C++ is the top choice of many programmers for creating powerf...
cpp-streams.ppt,C++ is the top choice of many programmers for creating powerf...cpp-streams.ppt,C++ is the top choice of many programmers for creating powerf...
cpp-streams.ppt,C++ is the top choice of many programmers for creating powerf...
 
C++ L01-Variables
C++ L01-VariablesC++ L01-Variables
C++ L01-Variables
 

Recently uploaded

Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 

Recently uploaded (20)

Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 

Practical basics on c++

  • 1. Professional slides for your work and your learning require a guide require an update Active tools in your new presentation: - operations buttons; - search commands; - bracket avaible; - active links to web. Press F5 to continue. version 1.2 >>
  • 2. Practical basics on writing C++ Basic operations quick guide
  • 3. Practical basics on writing C++ I/O and math operation symbols libraries to include heading and functions 1 #include <iostream> //proprocessor direcrive using namespace std; code for output cout << "Hello word!n; //this istruction can be write as //cout << "Hello word!" << endl;
  • 4. Practical basics on writing C++ I/O and math operation symbols libraries to include heading and functions 2 #include <iostream> //proprocessor direcrive using namespace std; code for input int number; //name of variable cin >> number; //reading by system of variable
  • 5. Practical basics on writing C++ I/O and math operation symbols sum of two operators + - subtraction of two operators division of two operators / * product of two operators calculation of the change in a division between two operators %
  • 6. Practical basics on writing C++ I/O and math operation symbols retention of a number in an element = == comparision of two elements increment of 1 ++ -- decrease of 1
  • 7. Practical basics on writing C++ I/O and math operation symbols member b of object a a.b *x pointed to by x adress of x &x x->y member y of object pointed to by x object pointed to by x x[n]
  • 8. Practical basics on writing C++ Mix input data with output messages code from text editor #include <iostream> using namespace std; int main () { cout << “Enter a number.n”; int number; cin >> number; cout << “You have endered the number “ << number << endl; //”number”; return 0; //this istruction return the command to OS and exits from the program } result from terminal Enter a number. 4 You have entered the number 4.
  • 9. Practical basics on writing C++ Condition if…else code from text editor #include <iostream> using namespace std; int main () { cout << “Enter a number.n”; int number; cin >> number; if (number < 10) { //condition cout << “The number entered is less than 10.n”; reutrn 0; } else cout << “The number entered is higher than 10.n”; return 0; } result from terminal Enter a number. 7 The number entered is less than 10. Enter a number. 25 The number entered is higher than 10. This function can be used to manage errors by user.
  • 10. Practical basics on writing C++ Condition switch code from text editor #include <iostream> using namespace std; int main () { cout << “Enter 1 to print a message, press 2 to exitn”; int number_selection; cin >> number_selection; switch (number_selection) { case 1: cout << “Hi!n”; return main (); case 2: return 0; default: cout << “Error! Please, press 1 or 2 keypass.n”; return main (); } } This function can be used to project a menu, for example. 1
  • 11. Practical basics on writing C++ Condition switch result from terminal Enter 1 to print a message, press 2 to exit. 1 Hi! Enter 1 to print a message, press 2 to exit. Enter 1 to print a message, press 2 to exit. 2 This function can be used to project a menu, for example. Enter 1 to print a message, press 2 to exit. 3 Error! Please, press 1 or 2 keypass. Enter 1 to print a message, press 2 to exit. 2
  • 12. Practical basics on writing C++ Cycles: for code from text editor #include <iostream> using namespace std; int main () { for (int a = 10; a < 20; a = a+1) { cout << “Value: " << a << “.n”; } return 0; } result from terminal Value: 10. Value: 11. Value: 12. Value: 13. Value: 14. Value: 15. Value: 16. Value: 17. Value: 18. Value: 19. Be careful to loops!
  • 13. Practical basics on writing C++ Cycles: while code from text editor #include <iostream> using namespace std; int main () { int n = 10; //initialisation while (n>0) { cout << n << ", "; --n; } cout << "liftoff!n"; } result from terminal 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, liftoff! Be careful to loops!
  • 14. Practical basics on writing C++ Cycles: do…while code from text editor //example of an echo machine #include <iostream> #include <string> using namespace std; int main () { string str; do { cout << "Enter text. "; getline (cin,str); cout << "You entered the following sentence.n " << str << 'n'; } while (str != "goodbye"); } result from terminal Enter text. Hello! You entered the following sentences. Hello! Be careful to loops! do…while executes at least once the operation, while while and for could not execute that.
  • 15. Practical basics on writing C++ Arrays and vectors: creations and operations code from text editor //declaration of array int name_of_array[10]; //the array’s size is 10 for(int i=0; i < 14; i++) //initialisarion of array { cout << name_of_array[10] << endl; //array’s printing } 1
  • 16. Practical basics on writing C++ Arrays and vectors: creations and operations another example #include <iostream> using namespace std; int foo[] = {16, 2, 77, 40, 12071}; int n, result=0; int main () { for ( n=0; n<5; ++n) { result += foo[n]; } cout << result; return 0; } result from terminal 12206 2
  • 17. Practical basics on writing C++ Classes public class #include <iostream> using namespace std; class rectangle { int width, height; public: rectangle (); rectangle (int,int); int area (void) { return (width * height); } }; rectangle::rectangle () {width = 5; height = 5; } rectangle::rectangle (int a, int b) {width = a; height = b; } int main () {r rectangle rect(3,4); rectangle rectb; cout << “rect area: " << rect.area() << endl; cout << "rectb area: " << rectb.area() << endl; return 0; } By default, in C++ the programmer insert private class type. 1
  • 18. Practical basics on writing C++ Classes output from bash rect area: 12 rectb area: 25 2
  • 19. Practical basics on writing C++ Compiling operation command from bash g++ <name_of_source_code>.cpp –o <name_of_executable>
  • 20. Practical basics on writing C++ Run command command from bash ./<name_of_executable>
  • 21. Index I/O and math operations symbols Mix input data with output messages Condition if…else Compiling operation Classes Cycles: for Cycles: while Cycles: do…while Arrays and vectors: creations and operations
  • 23.
  • 24. Get help for free! marco.izzottialessandro@gmail.com Priority avaible to anyone. Marco A. Izzotti Only for friends. 348 0530717 Avaible only for italians during days.