SlideShare una empresa de Scribd logo
1 de 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

Más contenido relacionado

La actualidad más candente

La actualidad más candente (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
 

Destacado

Power point 1
Power point 1Power point 1
Power point 1wilts2kl
 
PowerPoint1
PowerPoint1PowerPoint1
PowerPoint1Jessica
 
Csc1100 lecture03 ch03-pt1-s14
Csc1100 lecture03 ch03-pt1-s14Csc1100 lecture03 ch03-pt1-s14
Csc1100 lecture03 ch03-pt1-s14IIUM
 
Difference between linux and windows hosting
Difference between linux and windows hostingDifference between linux and windows hosting
Difference between linux and windows hostinganuradha_chawla
 
Basics of computer science
Basics of computer scienceBasics of computer science
Basics of computer sciencePaul Schmidt
 
Computer Engineer Powerpoint
Computer Engineer PowerpointComputer Engineer Powerpoint
Computer Engineer Powerpointguest845829
 
Computer science seminar topics
Computer science seminar topicsComputer science seminar topics
Computer science seminar topics123seminarsonly
 
Networking devices
Networking devicesNetworking devices
Networking devicesrupinderj
 
Social Networking Presentation
Social Networking PresentationSocial Networking Presentation
Social Networking PresentationAnusorn Kansap
 
Best topics for seminar
Best topics for seminarBest topics for seminar
Best topics for seminarshilpi nagpal
 
basics of computer system ppt
basics of computer system pptbasics of computer system ppt
basics of computer system pptSuaj
 

Destacado (17)

Power point 1
Power point 1Power point 1
Power point 1
 
PowerPoint1
PowerPoint1PowerPoint1
PowerPoint1
 
Choices
ChoicesChoices
Choices
 
Csc1100 lecture03 ch03-pt1-s14
Csc1100 lecture03 ch03-pt1-s14Csc1100 lecture03 ch03-pt1-s14
Csc1100 lecture03 ch03-pt1-s14
 
Plug and play services
Plug and play services Plug and play services
Plug and play services
 
Difference between linux and windows hosting
Difference between linux and windows hostingDifference between linux and windows hosting
Difference between linux and windows hosting
 
Chapter 2.datatypes and operators
Chapter 2.datatypes and operatorsChapter 2.datatypes and operators
Chapter 2.datatypes and operators
 
Basics of c++
Basics of c++Basics of c++
Basics of c++
 
Basics of computer science
Basics of computer scienceBasics of computer science
Basics of computer science
 
Cse ppt
Cse pptCse ppt
Cse ppt
 
Computer Engineer Powerpoint
Computer Engineer PowerpointComputer Engineer Powerpoint
Computer Engineer Powerpoint
 
Computer science seminar topics
Computer science seminar topicsComputer science seminar topics
Computer science seminar topics
 
Networking devices
Networking devicesNetworking devices
Networking devices
 
Social Networking Presentation
Social Networking PresentationSocial Networking Presentation
Social Networking Presentation
 
Best topics for seminar
Best topics for seminarBest topics for seminar
Best topics for seminar
 
basics of computer system ppt
basics of computer system pptbasics of computer system ppt
basics of computer system ppt
 
Slideshare ppt
Slideshare pptSlideshare ppt
Slideshare ppt
 

Similar a 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 a 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
 

Más de 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
 

Más de 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
 

Último

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 

Último (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 

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

Notas del editor

  1. Alt+8 to dsiplay in MSVS executable code