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

Name Size (bytes) Description Range
char 1 character or eight bit integer signed: -128..127

unsigned: 0..255

short 2 sixteen bit integer signed: -32768..32767

unsigned: 0..65535

long 4 thirty-two bit integer  signed: -231 .. 231-1

unsigned: 0 .. 232

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

unsigned: 0..65535

float 4 floating point number 3.4e +/- 38

(7 digits)

double 8 double precision floating point 1.7e +/- 308

(15 digits)

long double 10 long double precision floating point 1.2e +/- 4932

(19 digits)

bool 1 boolean 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

Télécharger aussi :

Laisser un commentaire

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