Monday, March 28, 2011


FOP CHAPTER 6
TOPIC : LOOP&WHILE


LOOP
#include<iostream.h>
main( )
{
//declare variable
//get input
cout<<"enter integer";
cin>>x;
//loop for
for(y=0:y<xy:y++)
{
cout<<"     "x;
}

WHILE
#include<iostream.h>
main( )
int x,y;
cout<<"enter an integer";
cin>>x;
//while(y<x)
cout<<"   "<<x;
y++;
}
}


FOP CHAPTER 5
STUDY DATE : 2 MAR 2011
TOPIC : IF ELSE ... SWICTH CASE......

EXAMPLE :

AGE   =    GENERATION
1-6      =  kids
7-12    =  child
13-21  =  teenagers 
 
22-30  =  adult
> 31    = old

if ..... else 

#include <iostream.h>
main ( )
{
declare variable
int age ;
// input
 
cout << " enter your AGE : " ;
cin >> age ;
//if else statement
 
if (age > = 1 II age <=6)
{cout << " you are kids ! " ;
else if ( age >=7 II age < = 12 )
{cout << '" you are child ! " ;
else if ( age >=13 II age <=21 )
{cout << " you are teenagers ! " ;
else if ( age <=22 II age <=30 )
{cout << " you are adult ! " ;
else if ( age > 30 )
{cout << " you are old ! " ;
else
{cout << "invalid selection" , ;
return 0 ;
}

swicth...case
 

#include < iostream.h>
main ( )
//declre variable
 
int age ;
//input
cout << " enter your age : " ;
cin >> age;
// swicth ... case statement
{ case ('age'>=1 II 'age' <= 6) : cout << " you are kids ! " ; break ;
case ( 'age'>=7 II 'age' <=12) : cout <<  " you are child ! " ; break ;
case ('age'>= 13 II 'age' <= 21) : cout << " you are teengers ! " ; break ;
case ( 'age' >= 22 II 'age' <=30) : cout << "you are adult ! " ; break ;
case ( 'age >30 ) : cout << " you are old ! " ; break ;
default : cout << " invalid selection " ;
}
return 0 ;
}

Tuesday, March 8, 2011

C++

buka interner:
go to start, pilih all progarm, cari boland c++















lepas tu boleh ar start buat progarmming..c++











Monday, March 7, 2011


Ni exercise yg miss ayuni bg, urmmm. Susah beb. Nik pening ak nk buat..

Nasib baek ade kawn2 yg tlg ajarkan... thank frens..
1) a) 5 * 2 % 3 + 25 / 5
        = (5 * 2) % 3 + (25 / 5)  settle bhgi nan darab dlu
        = (10 % 3) + 5  settle modulus dlu
        = 1 + 5
        = 6

   b) a = 5 , b = 6
       !(( a < 3 ) & & ( a = = 3 ) | | ( b > 9 ))
       = !(( 5 < 3 ) & & ( 5 = = 3 ) | | ( 6 > 9 ))   msok kn nilai a nan b dluAA
       = !((    0   ) & & (     0     ) | | (    0    ))   tntukan true / 1 or false / 0
       = !((    0   ) & & (     0     ) | | (    0    ))   settle kn & & dlu
       = !((    0    ) | | (    0    ))   br settle kn | |
       = !(0)   klu not / !, kne tebalek kn
       = 1 / True 
2) Identify the syntex error in the following program 
    include<iostream.h>  x letak simbol #
    mai()  ejaan sala, tetinggal hruf n
    {
     float allowance=300.00,salary;
    cout<<''Input Salary=";
    cin>salary;  sala simbol, ptot nye >>
    Tsalary=Sallary+Allowance;  formula sala, hruf T x perlu ade
    cout<<"salary is="<<salary;  lpas output, kne ltax return 0;
    }  

   JAWAPAN :
    
#include<iostream.h>
    main() 
    {
     float allowance=300.00,salary;
    cout<<''Input Salary=";
    cin>>salary; 
    salary=Sallary+Allowance; 
      cout<<"salary is=”<<salary;
     }

     3.write a program that will calculate the monthly salary for an employee that where saturday&sunday are considered as non working days .                                                                                            
 answer :
# include <iostream.h>
main ()
{
// declare variable
float noworkingdays;
f[oat salaryperdays;
float monthlysalary;
// input 1
cout <<"enter noworkingdays";
cin>> noworkingdays;
// input 2
cout <<"enter salaryperdays=";
cin>>"salaryperdays;
formula
monthly salary=noworkingdays*salaryperdays";
//output
cout<<"monthysalary<<monthlysalary;
return o
}


4.write a program that allowance their everage of 5 numbers that can be input by user.


answer:
# include < iostream.h>
main()
{
float no1
float no2
float no3
float no4
float no5
total average // input 1
cout<<"num 1";
cin>>num 1;
// input 2
cout<<"num 2";
cin>>num 2;
// input 3
cout<<"num 3";
cin>> num 3;
// input 4
cout<<" num 4";
cin>> num 4;
// input 5
cout<<"num5";
cin>> nmu 5;
// formula1
total= num1+num2+nmu3+num4+num5
// output
cout<<"total"<<total;
// formula
 average=total / 5
// output 2
cout<<"average"<<average;
return o
{
5.write a program that win calculate the area of rectangular,triangle&circle.
answer:
# include<iostream.h>
main()
}
// declare variable
float heigh;
float widh;
float area rectangle;
float radius;
float area circle;
float height;
float area triangle
// input 1
cout <<"enter height";
cin>>height;
// input 3
cout<<"enter width";
cin>>width;
//input 3
cout<<"enter radius";
cin >> radius;
// formula
area-rectangle=heightr*width;
// output 1 cout<<"area-rectangle="area-rectangle;
//formula 2
area-circle=3.14*radius*radius;
// output2
cout<<"area-circle="<<area-circle;
// formula 3
area=triangle=0.5*height*height;
// output3cout<<"area-triangle;"area -trinagle;
return o;
}



TUESDAY, FEBRUARY 8, 2011
#include <IDStream.h> //header
Main ( ) // start body
{ // Open curly braket
} // close curly braket
// comment hidden
//  1 baris coding
/ * , * / sume coding @ lbh dr 1 coding

Declare variable
Data_type              variable_name

Data type
Int
Integer
Float
Float
Decimal
Double
Double
Decimal
Char
Character
a-z /A-Z
String
String
Sentences
Const
Constant
Tak berubah

Rules:
1.     ~ Tengok formula
2.    ~Cari ade bape variable name
3.    ~Declare variable

Input:
Cout <<“----------------------” ;
Cin >>variable_name_that_had_declared;
 Rules: carefull dgn ejaan,huruf (kck & bsr)

Output:
Cout <<“----------------------”<<
variable_name_that_had_declared;

sample question!!!!!!!!!!

flow chart :




#include <iostream.h>//header
Main(   ) //start body
{  // Open curly braket
//declare variable
Float area;
Float radius;
// input 1
Cout <<“enter radius”;
Cin>> radius;
//formula
area = 3.14 *radius*radius
//output
Cout <<“answer”<<area ;
Return 0 ;
}  // close curly braket
//end baraket

* ciap pown tok chptr 2 nie...
chptr 2 nie agk ssh..tp kalo kite ley fhm n focus bnda nie sng jewk....hhehehe
ape yg pnting : kne wt step by step...
kalo kite da slh wt tok algoritm o pseudocode mknye kite akn slh gk wt bnda nie...
alert kt ejaan ea...jgn ade yg slh...

MONDAY, FEBRUARY 7, 2011
ALGORITHM – Is sequences of instruction to solve a problem…(ayt yg pngjg2)
PSEUDOCODE – Is the textual approach to illustrate an algorithm while flowchart is a graphical approach to illustrate an algorithm (ayt yg pndk)

sample question!!!!!!!!!!!!!!!!!!

example 1 :
Find the area of rectangle
Area = width * height
Algorithm
1.Get the width of rectangle
2.Get the height of rectangle
3.Calculate the area of rectangle with multiply width by height
4.Display the area of rectangle

Pseudocode
1.Read width
2.Read Height
3.Set the area = width * height
4.Print output


Flow chart


example 2:
find the area of celcius
celcius = (5/9) * ( fahrenheit-32)
Algorithm
1.get the fahrenheit of celcius
2.calculate celcius equal to five devide by name multiply by fahrenheit minus 32
3.display the area of celcius

pseudocode:
1.read fahrenheit
2.set the celcius = (5/9) * ( fahrenheit - 32 )
3.print output

flow chart :


example 3:
find the area of fahrenheit
fahrenheit =( 9/5 *( celcius + 32 ) )
Algorithm

1.get the celcius of fahrenheit
2.calculate fahrenheit equal nine devide by five multiply celcius plus 32
3.display fahrenheit

pseudocode
1.read celcius
2.set the fohrenheit ( 9/5 *( celcius + 32 ) )
3.print output


Flow chart


Thursday, February 10, 2011

dapat buat cacatan baru...

hii.. semua
mengantuk yer malam.. sejuk2 ni sedap tdo.. hehe
malam ni saya happy coz dapt wat 1 post kat forum lect-ayuni..
tapi tak tau la btol ke x.. but, saya dah tyr buat..
harp2 lepas ni dapt buat yg lebih baek dari ari ni..
selamat malam..

miggu kedua

aku belajar chapter1 and 2..
urmmm.. susah gak nak wat programming nie.. klu student IT
cam kacang jerk.. tapi, bagi budak business cam aku ni.. 
nemg ar blurr jerk.. hehe :(