Professional Documents
Culture Documents
type variable-name;
Meaning: variable <variable-name> will be a variable of type
<type>
Where type can be:
int //integer
double //real number
char //character
Example:
int a, b, c;
double x;
int sum;
char my-character;
2
Identifiers
A valid identifier is a sequence of one or more letters,
digits or underscore characters (_). Neither spaces nor
punctuation marks or symbols can be part of an
identifier. Only letters, digits and single underscore
characters are valid. In addition, variable identifiers
always have to begin with a letter. They can also begin
with an underline character (_ ), but in some cases
these may be reserved for compiler specific keywords.
C++ keywords
Keywords appear in blue in Visual C++.
Each keyword has a predefined purpose in the
language.
Do not use keywords as variable and constant
names!!
The complete list of keywords is on page 673 of the
textbook.
We shall cover the following keywords in this class:
C++ keywords
asm, auto, bool, break, case, catch, char, class, const,
const_cast, continue, default, delete,
do, double, dynamic_cast, else, enum, explicit, export,
extern, false, float, for, friend, goto,
if, inline, int, long, mutable, namespace, new, operator,
private, protected, public, register,
reinterpret_cast, return, short, signed, sizeof, static,
static_cast, struct, switch, template,
this, throw, true, try, typedef, typeid, typename, union,
unsigned, using, virtual, void,
volatile, wchar_t, while
Primitive Data Types
Name Size (bytes) Description Range
char 1 character or eight bit integer signed: -128..127
unsigned: 0..255
long double 10 long double precision floating point 1.2e +/- 4932
(19 digits)
#include<iostream>
#include "conio.h"
using namespace std;
void main(){
int num1=10;
int num2=9; Local variable
int answer = compute(num1,num2);
cout<<"Answer is ";
cout<< answer;
_getch();
}
Input and Output