www.cplusplus.com signed unsigned short int SHRT_MIN

Anuncio
www.cplusplus.com
signed
short int
int
long int
long long
needs
SHRT_MIN .. SHRT_MAX
INT_MIN .. INT_MAX
LONG_MIN .. LONG_MAX
LLONG_MIN .. LLONG_MAX
#include
unsigned
0
0
0
0
..
..
..
..
SHR_MAX
UINT_MAX
ULONG_MAX
ULLONG_MAX
<limits.h>
memory size: sizof operator
example:
cout << "size of int" << sizeof(int) << endl;
double p = 15.2; // global - not good
const double pi = 3.14159; // global constant
int main()
{
cout << p << endl; // 15.2 double
{
int p=22;
cout << p << endl; // 22
}
cout << p << endl; // 3.14
}
p=3.14;
...
if (a>0)
cout << "positivo" << endl;
else
cout << "no positivo" << endl;
...
...
if (a>0)
{
cout << "positivo" << endl;
b = 1;
}
else
{
cout << "no positivo" << endl;
b = 0;
}
...
if (a>0)
{
cout << "positivo" << endl;
}
else
{
if (a<0)
{
cout << "negativo" << endl;
}
else
{
cout << "zero" << endl;
}
}
if (a>0){
cout << "positivo" << endl;
}
else if (a<0)
{
cout << "negativo" << endl;
}
else
{
cout << "zero" << endl;
}
int grade;
..
switch (grade)
{
case 1: cout
case 2: cout
case 3: cout
}
<< "muy bien"; break;
<< "bien"; break;
<< "mal"; break;
int grade;
..
switch (grade)
{
case 1: cout
case 2: cout
case 3: cout
default: cout
}
<<
<<
<<
<<
"muy bien"; break;
"bien"; break;
"mal"; break;
"invalido"; break;
int grade;
..
switch (grade)
{
case 1: cout <<
case 2: cout <<
case 3: cout <<
default: cout <<
}
"aprobado"; break;
"aprobado"; break;
"no aprobado"; break;
"invalido"; break;
int grade;
..
switch (grade)
{
case 1:
case 2: cout << "aprobado"; break;
case 3: cout << "aprobado"; break;
default: cout << "invalido"; break;
}
..
int grade;
..
switch (grade)
{
case 1: cout
case 2: cout
case 3: cout
default: cout
}
<<
<<
<<
<<
"muy "; // no break
"bien"; break;
"mal"; break;
"invalido"; break;
For loop
int i;
int sum=0;
for (i=1;i<=100;i++)
sum = sum + i; // or sum += i
cout << sum << endl;
int sum=0;
for (int i=1;i<=100;i++)
sum = sum + i; // or sum += i
cout << sum << endl;
int p;
int n=100;
for (p = 1; p < n;
cout << p << endl;
int p;
int n=100;
for (p = 1; p < n;
cout << p << endl;
p = p + p) ;
p = p + p) /*nada*/ ;
while loop
int sum=0;
int i = 0;
while (i<=100)
{
sum = sum + i;
++i;
}
cout << sum << endl;
while loop
int sum=0;
int i = 0;
do
{
sum = sum + i;
++i;
}
while (i<=100)
cout << sum << endl;
Descargar