Posted in

C++ Variables declaration & assignments

C++

AN EXAMPLE

#include
int main()
{
int i=0;
double x=2.3;
char s[]= »Hello »;
cout<<i<<endl;
cout<<x<<endl;
cout<<s<<endl;
return 0;
}
1.cpp

LEXICAL ELEMENTS

Identifiers: case sensitive
nCount, strName, Strname
Reservered words
if, else, while
Operators
+, ==, &, &&, ‘? :’
Preprocessor Directives
#include, #if,

Primitive Data Types

NameSize (bytes)DescriptionRange
char1character or eight bit integersigned: -128..127

unsigned: 0..255

short2sixteen bit integersigned: -32768..32767

unsigned: 0..65535

long4thirty-two bit integer signed: -231 .. 231-1

unsigned: 0 .. 232

int* (4)system dependent, likely four bytes or thirty-two bitssigned: -32768..32767

unsigned: 0..65535

float4floating point number3.4e +/- 38

(7 digits)

double8double precision floating point1.7e +/- 308

(15 digits)

long double10long double precision floating point1.2e +/- 4932

(19 digits)

bool1boolean value

false → 0, true → 1

{0,1}

Variables declaration & assignments

#include
using namespace std;
int main()
{
int i,j,k;
int l;
i=10;
j=k=l=20; //j=(k=(i=20))
cout<<« i= »<<i<<endl;
cout<<« k= »<<k<<endl;
cout<<« l= »<<l<<endl;
i+=10; //i = i + 10;
i++; //i = i + 1;
cout << « i= »<<i<<endl;
} 2.cpp

Cours gratuitTélécharger le cours complet

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *