Wednesday, February 16, 2011

Chapter Two

 #include<iostream.h> //header
main( ) //start body
{ //open curly bracket
 //declare variable
float area;
float radius;
 //input 1
cout<<"Enter radius=";
cin>>radius;
 //fomula
area=3.14*radius*radius;
//output
cout<<"area="<<area;
return 0;
}//close curly bracket
 //end Body
step2 nak wat nye :
1) firstly ngok formula yg tlah dibagi ;
*example area utk circle is area=3.14*radius*radius

2) second,cari bpe banyak variable name yg ade dlm cnth yg diberi.

3) then, declare variable

4) after that, wt flow chart bdasarkan soklan yg dy bg
*cth : start > read radius > area=3.14*radius*radius > print output > end

5) haa dh settle semua tdi,bru leh start wt coding.. ade beberape pkare yg sgt penting dlm coding niy.. antarenye :
*in the 1st line mest msukkn #include<iostream.h>
*in the 2nd line maskkn main()
*3rd line jgn lupe wt { tok strating & pntup wat body
*all in flow chart kne tulis dlm body
*huruf depands pade soalan sama ade huruf kecik smua @ besar
*xbole ade space except 4 the certain part mcm comment, declare variable and input&output yg ade dlm ("") & return 0
*dlm coding,jgn lupe letak simbol semi colun;
Comment
  • //*utk 1 baris coding
  • /* , */ = utk ksuluruhan coding / >1 baris coding
  • depands pde u all nk jarak2 @ rapat2

Declare variable ( Start )
*wjib hafal & kne tau k..
    DATA TYPEINTEGER
    IntegerInteger (o-9)
    FloatFloat (decimals)
    DoubleDouble (decimals)
    CharCharacter (a-z / A-Z)
    StringString (Sentences)
    ConstConstant (pi=3.142)
    Input
           cout<<"________";
           cin>>variable_name_thae_had_declare ;

WAJIB TAU :
  • jgn salah ejaan,huruf besa @ kecik 
  • key in ikot soklan, jgn short form2
  • bahasa melayu= jgn wat bm plak. xbly suke2 wat short form k 
  • dlm ( " " ) tplang pde u all nk space @ x 
Output
         cout<<"______"<<variable_name_that_had_declared ;

No comments:

Post a Comment