Ni ialah soalan midterm last week..kitorang kena buat balik sebab ramai orang yang tak dapat full mark kat section A ni walaupun soalan ni senang...tak tau la apasal...time midterm ari tu soalan ni nampak macam susah je...nak dapat kan jawapan pun tak dapat...tapi time lepas midterm tengok balik kat soalan ni nampak senang pulak...heran2.....
*Yang ade underline kat bawah tu ialah jawapan...
SECTION A.
#include<iostream.h>
main()
{
float price=0,total;
int i;
for ( i =1;i<=3;i++)
{
cout<<"Enter price ["<<i<<"]:";
cin>>price;
total + = price;
}
cout<<"Total="<<total;
return 0;
}
Friday, April 1, 2011
Midterm examination question(FOP)
Posted by mohammad at 7:07 AM 0 comments
Wednesday, March 30, 2011
Assignment 1
Write a program.
********************
MESIN TIN MINUMAN
----------------------------
1.PEPSI 1.80
2.COCA COLA 1.90
3.F&N ORANGE 1.50
4.F&N MIRINDA 1.60
5.100 PLUS 2.00
Your Selection:______________Thank You!
Insert Your Money:______________Please Come Again
*your balance are:_________
*please insert _______________your money is___________not enough balance
Posted by mohammad at 5:24 AM 0 comments
Saturday, March 26, 2011
Assignment 2
1 2 3 4 5 6 7 8 9 10 11 12
2 4 6 8 10 12 14 16 18 20 22 24
3 6 9 12 15 18 21 24 27 30 33 36
4 8 12 16 20 24 28 32 36 40 44 48
5 10 15 20 25 30 35 40 45 50 55 60
6 12 18 24 30 36 42 48 54 60 66 72
7 14 21 28 35 42 49 56 63 70 77 84
8 16 24 32 40 48 56 64 72 80 88 96
9 18 27 36 45 54 63 72 81 90 99 108
10 20 30 40 50 60 70 80 90 100 110 120
11 22 33 44 55 66 77 88 99 110 121 132
12 24 36 48 60 72 84 96 108 120 132 144
Posted by mohammad at 9:29 AM 0 comments
For loop statement to while loop statement
Ni plak kitorang belajar pasal nak tukarkan for loop statement kepada while loop statement.
kat bawah ni contoh nak tukarkan statement ni....
#includde<iostream.h>
main()
{
//declare variable
int x,y;
//get input
cout<<"enter an interger=";
cin>>x,4
//loop for...
for(y=1; y<x; y++)
{
(cout<<" "<<x;
}
}
*yang kat atas ni ialah for loop.kalau ade soalan nak kite tukarkan kepada while loop, kite buat jer macam kat bawah ni...
#include<iostream.h>
main()
{
int x,y;
cout<<"enter an interger=";
cin>>x;
//while
y=1;
while(y<x)
{
cout<<"enter an interger= ";
y++;
}
}
Posted by mohammad at 9:04 AM 0 comments
If...else statement to switch...case statement
Dalam bab ni kitorang belajar camne nak tukar if...else statement kepada switch...case statement.
kat bawah ni ialah contoh camne nak buat statement ni...(kalau tak faham,buat2 faham jer...hehehe).
#include<iostream.h>
main()
{
//declare variable
int age;
//if else statement
if(age>=1 ll age<=6)
{cout<<"you are kids!;}
else if(age>=7 ll age<=12)
{cout<<"you are child babe!";}
else if(age>=13 ll age <=21)
{cout<<"you are teenager!";}
else if(age>=21 ll age<=30)
{cout<<"you are adult now!";}
else if(age>=30)
{cout<<"you are old,boo!";}
else
{cout<<"invalid selection";}
return 0;
}
*yg kat atas ni ialah if...else statement dan yang kat bawah ni pulak ialah switch...case statement.
#include<iostream.h>
main()
{
//declare variable
int age;
//input
cout<<"enter your age=";
cin>>age;
//switch case statement
switch(age)
{case('age'>=1 ll 'age'<=6):cout<<"you are kids!";break;
case('age'>=7 ll 'age'<=12):cout<<"you are child beb!";break;
case('age'>=13 ll 'age'<=21):cout<<"you are teenage!";break;
case('age'>=22 ll 'age'<=30):cout<<"you are adult now!";break;
case('age'>=30):cout<<"you are old!";break;
default:cout<<"invalid selection";
}
return 0;
}
Posted by mohammad at 8:39 AM 0 comments
Monday, March 7, 2011
Third week of FOP class
kelas untuk minggu ni senang sikit sebab kitorang belajar benda yang sama ngan last week..senang sikit nak paham...lecturer kitorang bagi kat kitorang some exercise untuk buat dalam group....nak ikut kan soalan tu takde la susah sangat tapi tak tau la apasal group kitorang tak dapat jawab soalan tu....group kitorang la yg paling terakhir berjaya menjawab soalan tersebut...huhuhuhu.....
Exercise in group
Question
Bahasa melayu=
Bahasa inggeris=
Matematik=
Sains=
Total=
Average=
Formula
total=bm+bi+math+sains
average=total/4
Answer
Start>>read Bm,Bi,Math,Sains>>total=Bm+Bi+Math+Sains,average=total/4>>display total,average>>end
#include<iostream.h>//header
main()//start body
{//open curly bracket
//declare variable
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<<"aveage="<<average;
return 0;
}//close curly bracket
//end body
Posted by mohammad at 8:24 AM 0 comments
Sunday, March 6, 2011
Second week of FOPclass
For this week ade jugak la faham sikit..itu pun di sebabkan rajin bertanya kepada yang expert....hehehe...
thanks to them kerana sudi memberi tunjuk ajar....
#include<iostream.h>//header
main()//start body
{//open curly bracket
}//close curly bracket
//end body
DECLARE VARIABLE
data type variable_ name
- int-integer
- float-float
- double-double
- char-character
- string-string
- const-constant
Question 1
Find the area of circle:
area=3.14* radius*radius
Answer
Start>>read radius>>area=3.14*radius*radius>>display output>>end
#include<iostream.h>//header
main()//start body
{//open curly bracket
//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 bracket
//end body
Question 2
Multiply and divide two FLOAT number, num 1 and num 2 with using the formula below:-
multiply=num 1*number 2
divide=num 2/num 1
Answer
Start>>read num 1,num 2>>multiply=num 1*num 2,divide=num 2/num 1>>display output>>end
#include<iostream.h>//header
main()start body
{//open curly bracket
//declare variable
float num 1;
float num 2
float multiply;
float divide;
//input 1
cout<<"num 1";
cin>>num 1;
//input 2
cout<<"num 2";
cin>>num 2;
//formula
multiply=num 1*num 2;
//output
cout<<"multiply="<<multiply;
//formula
divide=num 2/num 1;
//output
cout<<"divide="<<divide;
return 0;
}//close curly bracket
//end body
Posted by mohammad at 7:44 AM 0 comments
Friday, March 4, 2011
First week of FOP class
Question 1
Find the area of rectangle:
Area=Width*height
Answer
Algorithm
1. Get the celcius of fahrenheit
2. Calculate fahrenheit equal nine divide by five multiply celcius + 32
3. Display fahrenheit
Pseudocode
1. Read celcius
2. Set the fahrenheit=(9/5)*(celcius+32)
3. Print output
Flowchart
Srart>>Read celcius>>(9/5)*(celcius+32)>>Print output>>End
Posted by mohammad at 8:49 AM 0 comments