SlideShare a Scribd company logo
1 of 13
C++ Basics
Variables, Identifiers,
Assignments, Input/Output
Variables
variable can hold a number or a data of other types, it
always holds something. A variable has a name
the data held in variable is called value
variables are implemented as memory locations and
assigned certain memory address. The exact address
depends on computer and compiler.
we think as though the memory locations are actually
labeled with variable names
12.5
32
'c'
y
Temperature
Letter
1001
1002
1003
1004
1005
1006
1007
-Number 1008
1009
2
Identifiers
name of a variable (or any other item you define in program) is
called identifier
identifier must start with a letter or underscore symbol (_), the
rest of the characters should be letters, digits or underscores
the following are valid identifiers:
x x1 x_1 _abc sum RateAveragE
the following are not legal identifiers. Why?
13 3X %change data-1 my.identifier a(3)
C++ is case sensitive:
MyVar and myvar are different identifiers
3
What Are Good Identifiers?
careful selection of identifiers makes your program clearer
identifiers should be
short enough to be reasonable to type (single word is norm)
– Standard abbreviations are fine (but only standard abbreviations)
long enough to be understandable
two styles of identifiers
C-style - terse, use abbreviations and underscores to separate the words,
never use capital letters for variables
Pascal-style - if multiple words: capitalize, don’t use underscores
– camel Case – variant of Pascal-style with first letter lowercased
pick style and use consistently
ex: Pascal-style C-style Camel Case
Min min min
Temperature temperature temperature
CameraAngle camera_angle cameraAngle
CurrentNumberPoints cur_point_nmbr currentNumberPoints
4
Keywords
keywords are identifiers reserved as part of the language
int, return, float, double
they cannot be used by the programmer to name things
they consist of lowercase letters only
they have special meaning to the compiler
5
Keywords (cont.)
asm do if return typedef
auto double inline short typeid
bool dynamic_cast int signed typename
break delete long sizeof union
case else mutable static unsigned
catch enum namespace static_cast using
char explicit new struct virtual
class extern operator switch void
const false private template volatile
const_cast float protected this wchar_t
continue for public throw while
default friend register true union
delete goto reinterpret_cast try unsigned
6
Variable Declarations
every variable in C++ program needs to be declared
declaration tells the compiler (and eventually the computer) what kind of
data is going to be stored in the variable
the kind of data stored in variable is called it’s type
a variable declaration specifies
type
name
declaration syntax:
two commonly used numeric types are:
int - whole positive or negative numbers:
1,2, -1,0,-288, etc.
double - positive or negative numbers with fractional part:
1.75, -0.55
example declarations:
int numberOfBars;
double weight, totalWeight;
type id, id, ..., id;
known
type
list of one or
more identifiers
7
Where to Declare
the variables should be declared as close to the place where they are
used as possible.
if the variable will be used in several unrelated locations, declare it at the
beginning of the program:
int main() {
 right here
note that variable contains a value after it is declared. The value is
usually arbitrary
8
Assignment
assignment statement is an order to the computer to set the value of the
variable on the left hand side of the equation to what is written on the
right hand side
it looks like a math equation, but it is not
Example:
numberOfBars = 37;
totalWeight = oneWeight;
totalWeight = oneWeight * numberOfBars;
numberOfBars = numberOfBars + 3;
var = value;
9
Output
To do input/output, at the beginning of your program you have to insert
#include <iostream>
using std::cout; using std::endl;
C++ uses streams for input an output
stream - is a sequence of data to be read (input stream) or a sequence of data
generated by the program to be output (output stream)
variable values as well as strings of text can be output to the screen using cout
(console output):
cout << numberOfBars;
cout << ”candy bars”;
cout << endl;
<< is called insertion operator, it inserts data into the output stream, anything
within double quotes will be output literally (without changes) - ”candy bars
taste good”
note the space before letter “ c” - the computer does not insert space on its own
keyword endl tells the computer to start the output from the next line
10
More Output
the data in output can be stacked together:
cout << numberOf_Bars << ”candy barsn”
symbol n at the end of the string serves the same purpose as endl
arithmetic expressions can be used with the output statement:
cout << “The total cost is $” << (price + tax);
11
Escape Sequences
certain sequences of symbols make special meaning to the computer.
They are called escape sequences
escape sequence starts with a backslash (). It is actually just one special
character.
Useful escape sequences:
– new-line n
– horizontal tab t
– alert a
– backslash 
– double quote ”
What does this statement print?
cout << ”” this is a t very cryptic ” statement  n”;
12
Input
cin - (stands for Console INput) - is used to fill the values of variables with the
input from the user of the program
to use it, you need to add the following to the beginning of your program
using std::cin;
when the program reaches the input statement it just pauses until the user types
something and presses <Enter> key
therefore it is beneficial to precede the input statement with some explanatory
output called prompt:
cout << “Enter the number of candy bars
cout << “and weight in ounces.n”;
cout << “then press returnn”;
cin >> numberOfBars >> oneWeight;
>> is extraction operator
dialog – collection of program prompts and user responses
note how input statements (similar to output statements) can be stacked
input tokens (numbers in our example) should be separated by (any amount of)
whitespace (spaces, tabs, newlines)
the values typed are inserted into variables when <Enter> is pressed, if more
values needed - program waits, if extra typed - they are used in next input
statements if needed 13

More Related Content

What's hot

What's hot (20)

Basic Input and Output
Basic Input and OutputBasic Input and Output
Basic Input and Output
 
C programming Workshop
C programming WorkshopC programming Workshop
C programming Workshop
 
Input Output Management In C Programming
Input Output Management In C ProgrammingInput Output Management In C Programming
Input Output Management In C Programming
 
Introduction to C programming
Introduction to C programmingIntroduction to C programming
Introduction to C programming
 
Managing input and output operation in c
Managing input and output operation in cManaging input and output operation in c
Managing input and output operation in c
 
C programming(Part 1)
C programming(Part 1)C programming(Part 1)
C programming(Part 1)
 
C fundamentals
C fundamentalsC fundamentals
C fundamentals
 
Constants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya JyothiConstants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya Jyothi
 
Unit 3. Input and Output
Unit 3. Input and OutputUnit 3. Input and Output
Unit 3. Input and Output
 
Programming in C (part 2)
Programming in C (part 2)Programming in C (part 2)
Programming in C (part 2)
 
CP Handout#2
CP Handout#2CP Handout#2
CP Handout#2
 
Learning the C Language
Learning the C LanguageLearning the C Language
Learning the C Language
 
What is c
What is cWhat is c
What is c
 
Input output statement in C
Input output statement in CInput output statement in C
Input output statement in C
 
C programming(part 3)
C programming(part 3)C programming(part 3)
C programming(part 3)
 
7. input and output functions
7. input and output functions7. input and output functions
7. input and output functions
 
Unit ii ppt
Unit ii pptUnit ii ppt
Unit ii ppt
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’
 
Input And Output
 Input And Output Input And Output
Input And Output
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
 

Viewers also liked

Evaluation Question 4
Evaluation Question 4Evaluation Question 4
Evaluation Question 4hsmedia16
 
Excretory system
Excretory systemExcretory system
Excretory systemEdujunxion
 
herramientas de la web 2.0
herramientas de la web 2.0herramientas de la web 2.0
herramientas de la web 2.0mechitaaa
 
Beautiful colors of spring 2013
Beautiful colors of spring 2013 Beautiful colors of spring 2013
Beautiful colors of spring 2013 QSRC NITA Dongguk
 
управление персоналом лекции
управление персоналом лекцииуправление персоналом лекции
управление персоналом лекцииokyykg
 
How china could remain power in south east asia
How china could remain power in south east asiaHow china could remain power in south east asia
How china could remain power in south east asiasonichiba
 
Dockerfile at Guidewire
Dockerfile at GuidewireDockerfile at Guidewire
Dockerfile at GuidewireDocker, Inc.
 
正規言語でプログラミング
正規言語でプログラミング正規言語でプログラミング
正規言語でプログラミングRyoma Sin'ya
 

Viewers also liked (15)

Evaluation Question 4
Evaluation Question 4Evaluation Question 4
Evaluation Question 4
 
Excretory system
Excretory systemExcretory system
Excretory system
 
herramientas de la web 2.0
herramientas de la web 2.0herramientas de la web 2.0
herramientas de la web 2.0
 
Beautiful colors of spring 2013
Beautiful colors of spring 2013 Beautiful colors of spring 2013
Beautiful colors of spring 2013
 
Mapadepalco forrolele
Mapadepalco forroleleMapadepalco forrolele
Mapadepalco forrolele
 
Rao vat cua nhua upvc
Rao vat   cua nhua upvcRao vat   cua nhua upvc
Rao vat cua nhua upvc
 
Sound
SoundSound
Sound
 
управление персоналом лекции
управление персоналом лекцииуправление персоналом лекции
управление персоналом лекции
 
Scheme and syllabus for mba
Scheme and syllabus for mbaScheme and syllabus for mba
Scheme and syllabus for mba
 
E manual
E manualE manual
E manual
 
O TEMPO - PRESENTE DO ETERNO
O TEMPO - PRESENTE DO ETERNOO TEMPO - PRESENTE DO ETERNO
O TEMPO - PRESENTE DO ETERNO
 
How china could remain power in south east asia
How china could remain power in south east asiaHow china could remain power in south east asia
How china could remain power in south east asia
 
Dockerfile at Guidewire
Dockerfile at GuidewireDockerfile at Guidewire
Dockerfile at Guidewire
 
Via Crucis en obras de arte
Via Crucis en obras de arteVia Crucis en obras de arte
Via Crucis en obras de arte
 
正規言語でプログラミング
正規言語でプログラミング正規言語でプログラミング
正規言語でプログラミング
 

Similar to keyword

02a fundamental c++ types, arithmetic
02a   fundamental c++ types, arithmetic 02a   fundamental c++ types, arithmetic
02a fundamental c++ types, arithmetic Manzoor ALam
 
Chapter 3 - Variable Memory Concept
Chapter 3 - Variable Memory ConceptChapter 3 - Variable Memory Concept
Chapter 3 - Variable Memory ConceptDeepak Singh
 
Basics Of C++.pptx
Basics Of C++.pptxBasics Of C++.pptx
Basics Of C++.pptxDineshDhuri4
 
Fundamental of C Programming Language and Basic Input/Output Function
  Fundamental of C Programming Language and Basic Input/Output Function  Fundamental of C Programming Language and Basic Input/Output Function
Fundamental of C Programming Language and Basic Input/Output Functionimtiazalijoono
 
2 EPT 162 Lecture 2
2 EPT 162 Lecture 22 EPT 162 Lecture 2
2 EPT 162 Lecture 2Don Dooley
 
INPUT AND OUTPUT PROCESSINGPlease note that the material o.docx
INPUT AND OUTPUT PROCESSINGPlease note that the material o.docxINPUT AND OUTPUT PROCESSINGPlease note that the material o.docx
INPUT AND OUTPUT PROCESSINGPlease note that the material o.docxjaggernaoma
 
C++ programming language basic to advance level
C++ programming language basic to advance levelC++ programming language basic to advance level
C++ programming language basic to advance levelsajjad ali khan
 
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...RSathyaPriyaCSEKIOT
 
presentation_data_types_and_operators_1513499834_241350.pptx
presentation_data_types_and_operators_1513499834_241350.pptxpresentation_data_types_and_operators_1513499834_241350.pptx
presentation_data_types_and_operators_1513499834_241350.pptxKrishanPalSingh39
 
C++ Overview
C++ OverviewC++ Overview
C++ Overviewkelleyc3
 

Similar to keyword (20)

Declaration of variables
Declaration of variablesDeclaration of variables
Declaration of variables
 
02a fundamental c++ types, arithmetic
02a   fundamental c++ types, arithmetic 02a   fundamental c++ types, arithmetic
02a fundamental c++ types, arithmetic
 
Chapter2
Chapter2Chapter2
Chapter2
 
Introduction%20C.pptx
Introduction%20C.pptxIntroduction%20C.pptx
Introduction%20C.pptx
 
C++ lecture 01
C++   lecture 01C++   lecture 01
C++ lecture 01
 
Chapter 3 - Variable Memory Concept
Chapter 3 - Variable Memory ConceptChapter 3 - Variable Memory Concept
Chapter 3 - Variable Memory Concept
 
C++ programming
C++ programmingC++ programming
C++ programming
 
Basics Of C++.pptx
Basics Of C++.pptxBasics Of C++.pptx
Basics Of C++.pptx
 
Fundamental of C Programming Language and Basic Input/Output Function
  Fundamental of C Programming Language and Basic Input/Output Function  Fundamental of C Programming Language and Basic Input/Output Function
Fundamental of C Programming Language and Basic Input/Output Function
 
C Programming Unit-1
C Programming Unit-1C Programming Unit-1
C Programming Unit-1
 
2 EPT 162 Lecture 2
2 EPT 162 Lecture 22 EPT 162 Lecture 2
2 EPT 162 Lecture 2
 
INPUT AND OUTPUT PROCESSINGPlease note that the material o.docx
INPUT AND OUTPUT PROCESSINGPlease note that the material o.docxINPUT AND OUTPUT PROCESSINGPlease note that the material o.docx
INPUT AND OUTPUT PROCESSINGPlease note that the material o.docx
 
C++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWAREC++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWARE
 
C++ programming language basic to advance level
C++ programming language basic to advance levelC++ programming language basic to advance level
C++ programming language basic to advance level
 
AS TASKS #8
AS TASKS #8AS TASKS #8
AS TASKS #8
 
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
UNIT-1 notes(Data Types – Variables – Operations – Expressions and Statements...
 
presentation_data_types_and_operators_1513499834_241350.pptx
presentation_data_types_and_operators_1513499834_241350.pptxpresentation_data_types_and_operators_1513499834_241350.pptx
presentation_data_types_and_operators_1513499834_241350.pptx
 
Unit 2- Module 2.pptx
Unit 2- Module 2.pptxUnit 2- Module 2.pptx
Unit 2- Module 2.pptx
 
C++ Overview
C++ OverviewC++ Overview
C++ Overview
 
C notes for exam preparation
C notes for exam preparationC notes for exam preparation
C notes for exam preparation
 

More from teach4uin

Master pages
Master pagesMaster pages
Master pagesteach4uin
 
.Net framework
.Net framework.Net framework
.Net frameworkteach4uin
 
Scripting languages
Scripting languagesScripting languages
Scripting languagesteach4uin
 
State management
State managementState management
State managementteach4uin
 
security configuration
security configurationsecurity configuration
security configurationteach4uin
 
static dynamic html tags
 static dynamic html tags static dynamic html tags
static dynamic html tagsteach4uin
 
static dynamic html tags
static dynamic html tagsstatic dynamic html tags
static dynamic html tagsteach4uin
 
New microsoft office power point presentation
New microsoft office power point presentationNew microsoft office power point presentation
New microsoft office power point presentationteach4uin
 
.Net overview
.Net overview.Net overview
.Net overviewteach4uin
 
Stdlib functions lesson
Stdlib functions lessonStdlib functions lesson
Stdlib functions lessonteach4uin
 
storage clas
storage classtorage clas
storage clasteach4uin
 

More from teach4uin (20)

Controls
ControlsControls
Controls
 
validation
validationvalidation
validation
 
validation
validationvalidation
validation
 
Master pages
Master pagesMaster pages
Master pages
 
.Net framework
.Net framework.Net framework
.Net framework
 
Scripting languages
Scripting languagesScripting languages
Scripting languages
 
Css1
Css1Css1
Css1
 
Code model
Code modelCode model
Code model
 
Asp db
Asp dbAsp db
Asp db
 
State management
State managementState management
State management
 
security configuration
security configurationsecurity configuration
security configuration
 
static dynamic html tags
 static dynamic html tags static dynamic html tags
static dynamic html tags
 
static dynamic html tags
static dynamic html tagsstatic dynamic html tags
static dynamic html tags
 
New microsoft office power point presentation
New microsoft office power point presentationNew microsoft office power point presentation
New microsoft office power point presentation
 
.Net overview
.Net overview.Net overview
.Net overview
 
Stdlib functions lesson
Stdlib functions lessonStdlib functions lesson
Stdlib functions lesson
 
enums
enumsenums
enums
 
memory
memorymemory
memory
 
array
arrayarray
array
 
storage clas
storage classtorage clas
storage clas
 

Recently uploaded

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 

Recently uploaded (20)

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 

keyword

  • 2. Variables variable can hold a number or a data of other types, it always holds something. A variable has a name the data held in variable is called value variables are implemented as memory locations and assigned certain memory address. The exact address depends on computer and compiler. we think as though the memory locations are actually labeled with variable names 12.5 32 'c' y Temperature Letter 1001 1002 1003 1004 1005 1006 1007 -Number 1008 1009 2
  • 3. Identifiers name of a variable (or any other item you define in program) is called identifier identifier must start with a letter or underscore symbol (_), the rest of the characters should be letters, digits or underscores the following are valid identifiers: x x1 x_1 _abc sum RateAveragE the following are not legal identifiers. Why? 13 3X %change data-1 my.identifier a(3) C++ is case sensitive: MyVar and myvar are different identifiers 3
  • 4. What Are Good Identifiers? careful selection of identifiers makes your program clearer identifiers should be short enough to be reasonable to type (single word is norm) – Standard abbreviations are fine (but only standard abbreviations) long enough to be understandable two styles of identifiers C-style - terse, use abbreviations and underscores to separate the words, never use capital letters for variables Pascal-style - if multiple words: capitalize, don’t use underscores – camel Case – variant of Pascal-style with first letter lowercased pick style and use consistently ex: Pascal-style C-style Camel Case Min min min Temperature temperature temperature CameraAngle camera_angle cameraAngle CurrentNumberPoints cur_point_nmbr currentNumberPoints 4
  • 5. Keywords keywords are identifiers reserved as part of the language int, return, float, double they cannot be used by the programmer to name things they consist of lowercase letters only they have special meaning to the compiler 5
  • 6. Keywords (cont.) asm do if return typedef auto double inline short typeid bool dynamic_cast int signed typename break delete long sizeof union case else mutable static unsigned catch enum namespace static_cast using char explicit new struct virtual class extern operator switch void const false private template volatile const_cast float protected this wchar_t continue for public throw while default friend register true union delete goto reinterpret_cast try unsigned 6
  • 7. Variable Declarations every variable in C++ program needs to be declared declaration tells the compiler (and eventually the computer) what kind of data is going to be stored in the variable the kind of data stored in variable is called it’s type a variable declaration specifies type name declaration syntax: two commonly used numeric types are: int - whole positive or negative numbers: 1,2, -1,0,-288, etc. double - positive or negative numbers with fractional part: 1.75, -0.55 example declarations: int numberOfBars; double weight, totalWeight; type id, id, ..., id; known type list of one or more identifiers 7
  • 8. Where to Declare the variables should be declared as close to the place where they are used as possible. if the variable will be used in several unrelated locations, declare it at the beginning of the program: int main() {  right here note that variable contains a value after it is declared. The value is usually arbitrary 8
  • 9. Assignment assignment statement is an order to the computer to set the value of the variable on the left hand side of the equation to what is written on the right hand side it looks like a math equation, but it is not Example: numberOfBars = 37; totalWeight = oneWeight; totalWeight = oneWeight * numberOfBars; numberOfBars = numberOfBars + 3; var = value; 9
  • 10. Output To do input/output, at the beginning of your program you have to insert #include <iostream> using std::cout; using std::endl; C++ uses streams for input an output stream - is a sequence of data to be read (input stream) or a sequence of data generated by the program to be output (output stream) variable values as well as strings of text can be output to the screen using cout (console output): cout << numberOfBars; cout << ”candy bars”; cout << endl; << is called insertion operator, it inserts data into the output stream, anything within double quotes will be output literally (without changes) - ”candy bars taste good” note the space before letter “ c” - the computer does not insert space on its own keyword endl tells the computer to start the output from the next line 10
  • 11. More Output the data in output can be stacked together: cout << numberOf_Bars << ”candy barsn” symbol n at the end of the string serves the same purpose as endl arithmetic expressions can be used with the output statement: cout << “The total cost is $” << (price + tax); 11
  • 12. Escape Sequences certain sequences of symbols make special meaning to the computer. They are called escape sequences escape sequence starts with a backslash (). It is actually just one special character. Useful escape sequences: – new-line n – horizontal tab t – alert a – backslash – double quote ” What does this statement print? cout << ”” this is a t very cryptic ” statement n”; 12
  • 13. Input cin - (stands for Console INput) - is used to fill the values of variables with the input from the user of the program to use it, you need to add the following to the beginning of your program using std::cin; when the program reaches the input statement it just pauses until the user types something and presses <Enter> key therefore it is beneficial to precede the input statement with some explanatory output called prompt: cout << “Enter the number of candy bars cout << “and weight in ounces.n”; cout << “then press returnn”; cin >> numberOfBars >> oneWeight; >> is extraction operator dialog – collection of program prompts and user responses note how input statements (similar to output statements) can be stacked input tokens (numbers in our example) should be separated by (any amount of) whitespace (spaces, tabs, newlines) the values typed are inserted into variables when <Enter> is pressed, if more values needed - program waits, if extra typed - they are used in next input statements if needed 13

Editor's Notes

  1. Alt+8 to dsiplay in MSVS executable code