.
- .
, . .
.
, , , , , , , , void ( ).
: , (, ), .
void.
.
: , , .
,
char, signed char | -128127 | |
unsigned char | 0255 | |
int, signed int, short int, signed short int | -3276832767 | |
unsigned int, unsigned short int | 065535 | |
long int, signed long int | -21474836482147483647 | |
unsigned long int | 04294967295 | |
float | 3.4E-383.4E38 | |
double | 1.7E-3081.7E308 | |
long double | 3.4E-49323.4E4932 | |
pointer | ||
pointer |
(. ) .
int age=20, height=170; // ,
unsigned weight=height/2; //
long index; //
unsigned, short, long, int .
+ | , |
- | , |
* | |
/ | |
% | |
x= | , ={+,-,*,/,%} |
++ | ( 1) |
-- | ( 1) |
&& | ( ) |
|| | ( ) |
! | () |
= = | |
! = | |
> | |
< | |
>= | |
<= | |
& | (and) |
| | (or) |
^ | |
~ | |
>> | |
<< | |
x= | , x={&,|,^,>>,<<) |
float, double, long double.
float force=12.78, /* */
acceleration=1.234; /* */
double height; /* */
, (. ). % ( ).
|
|
char, signed char, unsigned char. .
char ch=$, ans=n, ascii_value=65;
char int, .
#include <stdio.h>
Main()
{
char ch=a, ans;
printf( ch+3=%c,ch+3);
ans=ch%3;
printf((\n\n ans=%d\n,ans);
}
:
ch+3=d
ans=1
char , . , , , .
:
char name[n];
name ;
n .
char str[80];
.
- .
, , . .
[ ] | |
() | |
. | |
-> | |
++, -- | / 1 ( .) |
sizeof | |
() | |
~ | |
! | |
- | |
& | |
* | |
*,/,% | , , |
+,- | , |
<<,>> | , |
<,>,<=,>= | |
= =,!= | , |
& | |
^ | |
| | |
&& | |
|| | |
?: | |
=,+=,=,*=,/=,%=,&= &=,^=,|=,<<=,>>= | |
, | , |
int. 0, , , . , . , . .
if (a>b||c>d||e>f)
, , , a>b, c>d, e>f.
.
,
if (b!=0.0&&a/b>12.4)
,
|
|
if (a/b>12.4&&b!=0.0)
. , .
&,|,^
. | ||
<< >> , , .
, 2, :
x>>n
x<<n
123=0000000001111011
123<<5 -> 0000111101100000=3936
123>>1 -> 00000000000111101=61
: =, +=, -=, *=, /=, %=, ++ --.
. , . . .
a=(b=c)*d;
b c, d a.
a=b=c=d=e=f=0;
+=, -=, *=, /= , :
a+=b; -> a=a+b; a-=b; -> a=a-b; a*=b; -> a=a*b; a/=b; -> a=a/b;
++ -- () () 1 . :
++a,++ a 1 () .
--a,-- a 1 () .
#include <stdio.h>
Main()
{
int a,b,c=3,d=4,f=3,g,h=5,z=6,i;
a=z+(b=c*d*f+(g=h+(i=3)));
printf(%d\n,a);
}
50.
sizeof
, . , . , . , .
#include <stdio.h>
Main()
{
Float a;
Int b;
Char c;
float d[500];
printf(\n %d, sizeof(int));
printf(\n %d, sizeof(double));
printf(\n a %d, sizeof a);
printf(\n d %d, sizeof d);
}
2