You are on page 1of 50

2012/13.

_____________________________________________________________

3.
""

""
-
-

( )
""

"C"
1.

ime_promenljive = izraz ;
x =x+y;

lvrednost

1.

""

y

y

1.
""

{
pom = x ;
x = y ;
y = pom ;
}

2.
+, -, *, /, %

a+b
ab
b
a:b
a mod b

C
a+b
a-b
a*b
a/b
a%b

2.
+, -, *, /, %
_____________________________________________________________

x y:
x/y - ,

x%y -

2. +, -, ++, --

/ ( + / - )
( ++ )
++ = +1
( -- )
= a-1

2. +, -, ++, --

int a = 0, b = 0;

++;

++;

--;

--;

=b++;

a=++b;

3.
sizeof(char)

sizeof (short)

sizeof(int)

2/4

sizeof(long)

sizeof(unsigned char)

sizeof (unsigned short)

sizeof(unsigned int)

2/4

sizeof(unsigned long)

sizeof(float)

sizeof(double)

4.

: (tip)

sizeof(char) < sizeof (short) sizeof(int) sizeof(long)
sizeof(float) < sizeof(double)

( )
char

short

int

long

float

double

4.

int x = 5;
float y = 10.3, z;
z = x * y;

x : 5.0000000
: 51.5000000
z
(x*) int

z 51.0000000

z = (int) (x * y);

4.

int x = 10, y = 3;
float z;

( )
z = x / y;
z 3.0000000
x 10.0000000

z = (float) x / y;

y
3.0000000
z 3.3333333

5.

==

x == y

!=

x != y

<

<

x<y

<=

x <= y

>

>

x>y

>=

x >= y



x y

x y

x
y
x
y
x
y
x
y

if
________________________________________________________


:

( )


if
________________________________________________________

if ( relacijski_izraz )
naredba1 ;
naredba2 ;


if

if
________________________________________________________

if ( relacijski_izraz )
{
naredba1 ;
naredba2 ;
]
naredban ;
}
naredban+1 ;


if

else if
________________________________________________________
if ( relacijski_izraz )
{
naredba11
naredba12
]
naredba1n
}
else
{
naredba21
naredba22
]
naredba2n
}


1.


2.

if if
________________________________________________________
if ( rel_izraz1 )
{
if(rel_izraz2)
{
naredba11
naredba12
]
naredba1n
}
}
else
{
naredba21
naredba22
]
naredba2n
}




1.



2.

if if
________________________________________________________
if ( rel_izraz1 )
if(rel_izraz2)
{
naredba11
naredba12
]
naredba1n
}
else
{

naredba21
naredba22
]
naredba2n

1.

2.
2.

1.
2.

2.

if else
________________________________________________________

if ( rel_izraz1 )
{
naredba11
naredba12
]
naredba1n
}
else
if(rel_izraz2)
{
naredba21
naredba22
]
naredba2n
}




1.




2.

6.

&& ( AND )

|| (OR )

! (NOT)

6.

0 && 0
0 && 1
1 && 0
1 && 1

_____
0
0
0
1

6.

0 || 0
0 || 1
1 || 0
1 || 1

_____
0
1
1
1

6.

!0
!1

_____
1
0

6.

if( x >= -10 && x <= 10 )


printf(\nVrednost je u opsegu od -10 do +10);
if( x < -10 || x > 10 )
printf(\nVrednost je van opsega od -10 do +10);
if ( x==0 )

if( !x )

if ( x!=0)

if( x )

7.


(izraz1) ? (izraz2) : (izraz3)

7.

ime_prom = (izraz1) ? (izraz2) : (izraz3) ;

if(izraz1)
ime_prom = izraz2;
else
ime_prom = izraz3;

7.

max = (x>=y) ? (x) : (y) ;

if(x>=y)
max = x;
else
max = y;

7.

printf(\nmaximum je %d, (x>=y) ? x : y);

if(x>=y)
printf(\nmaximum je %d, x);
else
printf(\nmaximum je %d, y);

8.


~ ( )
<< ( )
>> ( )
& ( )
| ( )
^ ( )

8.



1.
~0
~1

_____
1
0

8.

x=x<<1

1 0 1 0 1 0 1 0 1 0 1 0

0 1 0 1 0 1 0 1 0 1 0 0

8.


1 1 0 0 1 1 0 0 1 1 0 0

0 1 1 0 0 1 1 0 0 1 1 0

x=x>>1

8.



1. 2.
0 & 0
0 & 1
1 & 0
1 & 1

_____
0
0
0
1

8.



1. 2.
0 | 0
0 | 1
1 | 0
1 | 1

_____
0
1
1
1

8.



1. 2.
0 ^ 0
0 ^ 1
1 ^ 0
1 ^ 1

_____
0
1
1
0

8.

if ( x & ( 1 << ( n-1 ) )


printf(%d. bit ima vrednost 1, n);


n- x

x = x | ( 1 << ( n-1 ) );

n-
x 1

x = x & ~( 1 << ( n-1 ) );

n-
x 0

x = x ^ ( 1 << ( n-1 ) );

n-
x (1 0 0 1)

9.


+=
-=
*=
/=


x
x
x
x

+=
-=
*=
/=

%=
&=
|=
^=
<<=
>>=

x
x
x
x
X
X

%= y
&= y
|= y
^= y
<<= y
>>= y

y
y
y
y


x = x + y
x = x y
x = x * y
x = x / y
x
x
x
x
x
X

=
=
=
=
=
=

x
x
x
x
x
x

% y
& y
| y
^ y
<< y
>> y

10. ""

&

( )

[ ]

->

""

15
14
13
12
11
10
9
8
7
6
5
4
3
2

[ ] ( ) . ->
! ~ ++ -- + - & (tip) sizeof()
* / %
+ << >>
< <= > >=
== !=
&
^
|
&&
||
?:
= += -= *= /= &= ^= |= <<= >>=


""

stdio.h

/ a

ctype.h

math.h
time.h
string.h




: ,
, ,
m

stdlib.h

/
"" stdio.h
_____________________________________________________________


int znak;
znak = getchar( );


putchar( znak );

tastatura

ekran

/
"" stdio.h
________________________________________________________

getchar() / putchar()
scanf() / printf()
scanf(%c, &znak);
printf(%c, znak);

c:\>q
c:\>q

Enter

( )

znak = getchar();
putchar(znak);

c:\>S
c:\>S

Enter

( )

getchar();

( )


"" ctype.h
________________________________________________________

ASCII ,
( 0 ):
int c;
c= getchar();
isdigit(c) c
isupper(c) c
islower(c) e c
isalpha(c) c
isalnum(c) e c
isprint(c) e c


"" ctype.h
________________________________________________________

if
if ( isdigit(c) )

if( c >= 0 && c <= 9 )

if ( isupper(c) )

if( c >= A && c <= Z )

if ( islower(c) )

if( c >= a && c <= z )


"" ctype.h
________________________________________________________


ASCII
:
toupper( )
tolower( )

int c;
c = getchar();

c = topupper(c);
putchar(c);


"" math.h

sin(x)

sin(x)

cos(x)

cos(x)

tan(x)
exp(x)
log(x)
log10(x)
sqrt(x)
fabs(x)
pow(x,y)

tg(x)
ex
ln(x)
log10(x)
x
|x|
xy


_______________________________________________________________________


( 3. O)
3.
(O, )

3.


2012/13.
_____________________________________________________________

3.
""

You might also like