Monday, 28 March 2011

WEEKLY REFLECTION 4

_seperti biase,kami diberi rehat selama 1 jam.

-selepas rehat,kami belajar chapter 4 iaitu operators and expressions.

-kami belajar ARITHMETIC OPERATORS,RELATIONAL OPERATORS,LOGICAL OPERATORS DAN ASSISMENT OPERATORS.

-Pn.Ayuni memberi kami exercise dan kami diberi tempoh selama 45 minit untuk menyiapkannya.

 - setiap group hendaklah menyiapkannya dan setiap wakil ahli group prelu membuat jawapan didepan.


CHAPTER 4 OPERATORS AND EXPRESSIONS.
4.1 Operators
-   C++ is very rich in built-in operators.
-  Operators triggers some computations when applied to operands in an expression.
- The commonly use operators are as follows :-
    a) Arithmetic Operators
    b) Relational Operators
    c) Logical Operators
    d) Assignment Operators

- Table 4-1 shows the commonly use operators in C++ programming language.

Arithmetic Operators
Relational Operators
Logical Operators
Assignment Operators
+
>

&&
=
-
<

||

*
>=
!

/
<=


%
==



INCREMENT AND DECREMENT OPERATOR

- Increment  -  Pro-increment   (++N)
                    - Post-increment  (N++)

- Decrement  - Pro- decrement   (--N)
                      - Post-decrement   (N--)
- For Example :-

 Int n ;                                                                            Int n ;
n = 5                                                                              N=5

cout << n, 5                                                                   cout << n, 5
cout << ++N ; 1+5 =6                                                    cout << N++ ;
cout << N ; 6                                                                 cout<< n ;  




Int M;                                                                                      Int M ;       
M= 9                                                                              M = 10
         
Cout << m; 9                                                                 cout << m ; 10
Cout << --M ; 8                                                             cout << M-- ; 10-1 =9
Cout << M ; 8                                                                cout << M ; 9


LOGICAL OPERATING

M
N
M&&N
M||N
0
0
0
0
1
0
0
1
0
1
0
1
1
1
1
1

!(M&&N)
!(M||N)
!M
!N
1
1
1
1
1
0
1
0
1
0
0
1
0
0
0
0


















! (M&&N) && (M||N)
!(M) || !(N)
1
1
0
1
0
1
0
0

For Example :-

++ a + --b * 4  > ++n  && p++ + q-- * 4 < x++ + 4

= 3 + 2 * 4 > 3* 2 + 4 &&      3 + 2 * 4 < 3 * 2 + 4
= 3 + 8 > 6 + 4            &&      3 + 8 < 6 + 4
= 11 > 10                     &&      11 < 10
=    1                            &&           0
                                      0

No comments:

Post a Comment