.
. , : ( ) . . . . . , .
:
1. char ( character ) 1 (8 ) . 0..255.
2. int ( integer ) . 4 (32 ). 0..4294967295 2147483648.. 2147483647.
3. long 8 (64 ). 0..264-1
:
1. float .
2. double .
:
. , , 0, , , 0 .
: .
, int char. , .
. :
signed ;
unsigned ;
void - ;
:
signed int myVariable; int , myVariable.
.
, . . :
#define
: #define MY_CONSTANT 100
MY_CONSTANT 100. , .
.
, . , . int myVariable. , :
|
|
int *pmyVariable=0;
, pmyVariable int. , , . . myVariable .
pmyVariable = &myVariable;
, , . myVariable pmyVariable , . (*) , :
*pmyVariable;
.
:
& ;
* , ;
- , ;
+ ;
~ ;
! ;
++ ;
- - .
() :
) :
+ ;
- ;
) :
* ;
/ ;
% ;
) :
<< , ;
>> , ;
) :
& ;
| ;
^ ;
) :
< ;
> ;
<= ;
>= ;
== ;
!= ;
) :
&& ();
|| ();
) :
= ;
*= ;
/= ;
%= ;
+= .
: (=) (==). , .
.
. ;. . , .
if.
if (, ) , , .
if :
if ()
{
1; // ,
|
|
}
else
{
2; // ,
}
, .
. .
While.
while , .
while()
{
;
}
while . , :
Do w hile.
do while. , , .
do
{
;
}
while();
dowhile .
For.
for. , : , . for , , . .
for(1; 2; 3)
{
;
}
. . .
. continue. , , . break.
.
, . main(). . main() . , , . . , . :
. , . . .
int myFunction(); , myFunction int.
. . :
void myFunction(int a, int b);
, , int . , :
myFunction(10, 20).
a 10, b 20.
, . 3 :
- , #include;
- , .
- , .
|
|
:
[ ] ();
.
{
}
:
int myFunction(int a, int b)
{
a:=a+1;
b:=b*b;
return a; //
}
, R=1 . 0 10 , 1 .
:
. , : /* */ // . , .
, . , , . , :
float current=0; - c current, float ( ) 0.
for.
voltage=voltage_lower_limit -
voltage < voltage_upper_limit
voltage=voltage+1 .
printf() . :
int printf( , 1,.., N);
, . :
| |
%c | |
%d | |
%f | |
%u | |
%x |
, , . (%) .
%.3 3.
, :
:
getPower printPower.
1.
, E24 ( ).
E24: 1; 1,1; 1,2; 1,3 ; 1,5; 1,6; 1,8; 2.
, 1271 1300 .
2.
, :
3.
(char, int, float, double), . , , .
sizeof. :
int sizeof( char, int, float, double);
4. . . .
|
|
: . , , .
: , , .
: , , , , , . . 3-6 .
.
, , .. , .
. .
. | ||
, . | ||
\ | ||
\ | ||
() | (). | |
. |
.
If
if () .
:
1.
if( )
{
, ;
, ;
, ;
}
else
{
, ;
, ;
, ;
}
2.
if( )
{
, ;
, ;
, ;
}
3. , ( , ).
if( ) 1 ;
else 2 ;
, b, . :
int a=10; int b=7; if(b<a) { a = a * a; printf ( = %d, a); } else { b = b * b; printf ( = %d, b); } |
C ase
Switch\Case , .
switch()
{
case 1:
, == 1;
break;
case 2:
, == 2;
break;
case 3:
, == 3;
break;
.
.
.
default:
, ;
break;
}
, . :
float x = 3.14; float result = 0; int key = 2; switch(key) { case 1: result=sin(x); break; case 2: result=cos(x);; break; case 3: result=tan(x); break; default: printf ( ); break; } printf( %f, result); . |
W hile
while(). , .
while( )
{
, ;
, ;
, ;
}
, f. :
int f = 10; int i = 0; int result = 0; while(i <= f) { result=result*i; i++; } printf( %d, result; |
|
|
D o while
do while ( ). : . 1 \ .
do
{
;
;
;
} while( );
, , 1 1000. :
int i= 10; int sum = 0; do { i++; sum=sum+i; } while(i < 1000); printf( %d, result, sum); |
F or
for. , .
for( 1; 2; 3)
{
;
;
;
}
1 ; 2 ; 3 .
, , 1 1000.
:
int i; int sum = 0; for(i=0; i <= 1000; i++) { sum=sum+i; } printf( %d, result, sum); |
, . , , . . , . :
. :
_ ( )
{
_;
_;
}
, :
int Square(int x)
{
int result=0;
result=x*x;
return result;
}
Square. , . x int. ( , ). . int result, . , return ( . ). . result. . int.
.
, , . :
_ ( );
- , , .
, Square 2, 3, 4.
int s =0;
s = Square (2); // 2.
printf (% d , s); // S
s = Square (3); // 3.
printf (% d , s); // S
s = Square (4); // 4.
printf (% d , s); // S
4, 9, 16.
(x=2, . .).
:
, . void ( . ).
Delay :
void Delay(int time)
DelayOneSecond :
void DelayOneSecond (void)
, . 3 :
1. , , .
2. . . :
[ ] ();
3. *.h, #include; *.c
1. , . . .
2. , , , . . .
scanf.
:
int x=0;
scanf(Vvedite x %d \n, &x);
x.
3. , , . . .
4.
y=x+x3/3!++x2n+1/(2n+1)! n . x n. .