Saturday, March 26, 2011

CHAPTER 4

1) Arithmetic operators :
    + + (Unary Plus)
    - - (Unary minus)
    + (Addition)
    - (Substraction)
    * (multiplication)
    / (Floating-point division / Integer division)
    % (Modulus)
Dlm C++, ade increament nan decrement operator..
    + + (Pre-increment) e.g + +m
    + + (Post-increment) e.g m+ +
    - - (Pre-decrement) e.g - -n
    - - (Post-decrement) e.g n- -

 
SOALAN :        a = 2 , b = 3
                      m = 2 , n = 3
                       p = 2 , q = 3
                       x = 2 , y = 3            

(+ + a) + (- - b) * 4 > (+ + m) * (- - n) + 4

JAWAPAN :
               

2) Relational operators :
    < (Less than)
    > (Greater than)
    = = (Equal to)
    < = (Less than or equal to)
    > = (Greater than or equal to)
    ! = (Not equal to)

3) Logical operators : (0/False , 1/True)
    & & (AND) ----> ade je 0 mesti 0/false
    | | (OR) ----> ade je 1 mesti 1/true
    ! (NOT) ---->
    !(& &) (NOT AND) ---->
    !(| |) (NOT OR) ---->  | |
 e.g
 
 
Exercise 2 :
Bahasa melayu=
Bahasa inggeris=
Matematik=
Sains=
Total=
Average=
total=bm+bi+math+sains
average=total/4

Formula :
#include<iostream.h>//header
main()//start body
{//open curly bracket
float bm;
float bi;
float math;
float sains;
float total;
float average;
//input 1
cout<<"bahasa melayu=";
cin>>bm;
//input 2
cout<<"bahasa inggeris=";
cin>>bi;
//input 3
cout<<"matematik=";
cin>>math;
//input 4
cout<<"sains=";
cin>>sains;
//formula
total=bm+bi+math+sains;
//output
cout<<"total="<<total;
//formula
average=total/4;
//output
cout<<"average="<<average;
return 0;
}//close curly bracket
//end body

No comments:

Post a Comment