BLOGGER TEMPLATES AND TWITTER BACKGROUNDS »

Sunday, March 27, 2011

dedicate 4 miss

 miss ayuni time kasih sebab da ajar sye nari pasal assigment nie...
hehehhee
sye da try wat gk mule2 error lme2 ok da,,,hehehhe
belaja dr kesilapan,,,,
TQ MISS AYUNI.....

assigment 2

assigment wat loop....
step 1


step 2
step 3
step 4
step 5
step 6
step 7


kalo time run click jewk kt run,,,tp dye xkuar...so kne g kt window n click kt output...
ok da ciap

Saturday, March 26, 2011

exercise before exam

QUESTION 1
change the if....else statements below to switch.....case statements:
#include <iostream.h>
main()
{
int nom A,nom B,Selection,Value;
cout<<"enter 2 numbers:";
cin>>nomA >>nomB;
cout<<"1.addition";
cout<"2.subtraction";
cout<<"3.multiply";
cout<<"4.division";
cin>>selection;
{
if (selection ==1)
{value =nomA + nomB;}
else if (selection ==2)
{value =nomA - nomB;}
else if (selection ==3)
{value =nomA * nomB;}
else if (selection ==4)
{value =nomA / nomB}
else
cout<<"invalid selection";}
<<"the value is:"<<value;
}
ANSWER:

#include <iostream.h>
main()
{
int nom A,nom B,Selection,Value;
cout<<"enter 2 numbers:";
cin>>nomA >>nomB;
cout<<"1.addition";
cout<"2.subtraction";
cout<<"3.multiply";
cout<<"4.division";
cin>>selection;
switch (selection)
{case 1:value=nomA + nomB;break
case 2:value=nomA - nomB;break
case 3:value=nomA * nomB;break
case 4:value=nomA / nomB;break
default cout<<"invalid selection";
cout <<"the value is"<<value;
}
return 0;
}
QUESTION 2
change for loop statement below to while loop.
#include <iostream.h>
main()
{
int i,power 2;
for (i=1;i<=9;i++)
{
power 2= i * i;
cout<<"    "<<i<<"power 2"<< power 2;
}
}
ANSWER
#include <iostream.h>
main()
{
int i,power 2;
while
i = 1;
while ( i <=9 )
{
power 2 = i * i;
cout <<"   "<< i << "power 2" << power 2;
i++;
}
}
QUESTION 3
write a program that input 2 numbers.compare and display only the biggest number.if the numbers are same,display the numbers are same
ANSWER
#include <iostream.h>
main()
{
int num1,num2;
cout<<"enter 2 numbers:";
cin >> nomA >> nomB;
//if...else statement
if (num 2 > num 1)
{ cout <<"num 2 is bigger than num 1";}
else if (num 2 == num 1)
{ cout <<"num 2 is same as num 1";}
else
{ cout <<"invalid selection";}
return 0;
}

QUESTION 4
write a programming using for loop that recive pricess of 3 products.calculate the price that must be paid after 10% discount is given to every customer.
ANSWER
#include <iostream.h>
main()
{
int x,price,total discount;
for (x=1;x<4;x++)
{
cout<<"price [ "<< x << " ] : ";
cin>>price;
}
total + price;
}
cout<<"total = " << total;
discount = total * 0.01;
cout<<"discount = "<<discount;
return 0;
}

QUESTION 5
what is the output for the following program segment
I) int x=20;
for (int i=5;i<=x;i++)
{
cout <<1;
i = 1 + 4;
}
ANSWER:
5
10
15
20

II) Int mul = 1;
do
{
mul = mul * 2;
cout <<"the mul is :"<<mul;
mul+++;
}
while (mul<10)
ANSWER
1
3
7

LOOP & WHILE

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

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

LUAHAN PERASAAN

hari nie da abez exam tok mid term,,,,
lege rasenye,,,,tp penutup exm td paper FOP...
woooowww mmg xdpt nk skor,,,hahhaha
w'pown ms da bg clue tp xcnfdnt nk jwb....
xpela da try  skg tinggal tawakal jewk,,,,
arinie sgt2 ont coz,,,abez jewk exam td troz g pustakaan  cr bahan nk  wt assgmnt MS...
pas ue smpai uma troz bkak laptop update blog....
wargggghhhhh pnt sgt2,,,,,
sok kls ag....hahahha
serius mmg pnt sgt2,,,,,
ok la time nnk tido,....
nite sume,,,:-)

assigment 1

write as program.
***************************
MESIN TIN MINUMAN
----------------------------------
JENIS                            RM
----------------------------------
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:
insert your money :

*your balance are_______________
*please insert ______________ your mmoney is not enough !!!!!!:________________


THANK YOU!!!!
PLEASE COME AGAIN

CODING!!!!!!!!!!!!
STEP 1

STEP 2
STEP 3
STEP 4
STEP 5
STEP 6
STEP 7
STEP 8 : nie cth kalo xkurang duit
STEP 9
STEP 10
STEP 11
STEP 12
STEP 13: cth kurang duit
STEP 14
STEP 15
p/s tq 4 miss ayunie....kerana da ajar sye

JOM STDY IF...ELSE OR SWITCH CASE...






bnda nie ley jd if,,,else or switch case,,,depends on question la k...
if....else statement
#include <iostream.h>
main ()
{
declare variable
int age;
//input
cout<<"enter your age =";
cin>>age;
//if..else statements
{ cout <<"your are child !";}
else if (age > = 7 ll age < = 12)
{ cout <<"you are teenager !";}
else if (age > = 22 ll age < = 30)
{cout <<"you are adult now!!";}
else if (age >30)
{ cout <<"you are old booooo.....";}
else
{cout<<"invalid selection";}
return o;
}

SWITCH CASE

#include <iostream.h>
main ()
{
declare variable
int age;
//input
cout<<"enter your age =";
cin>>age;
switch..case statements
switch (age)
{ case ('age'> =1 ll age <= 6):cout<<"you are kids!";break;
case ('age'>=13 ll 'age' <= 12):cout<<"you are adult!";break;
case ('age'>=13 ll 'age'<=21):cout<<"you are teenager!";break;
case ('age'>= 22: ll 'age' <=30):cout<<"you are adult now!!";break;
case ('age'>=30):cout<<"you are old booooo.....";break;
default: cout<<"invalid selection";
}
return 0;
}


exercise 2

QUESTION 1:
a) intializing variable pi with the value 3.14
ans: float pi = 3.14
b) Declare a variable named parameter with double data type
ans: Double perimeter;
c) Give instruction that allowed user to input data
ans: cout<< "enter your data";
       cin>> data;
d) Input number of computer using variable
ans:cout<<"enter number";
      cin>>number;
QUESTION 2:
Change the if....else statement below to switch....case statement
#include <iostream.h>
main ()
{
int selection,quantity;
float price;
cout<<"1.pen = Rm0.50";
cout<<"2.pencil = Rm0.30";
cout<<"3.ruler = Rm0.20";
cout<<"4.eraser = Rm0.10";
cin>>selection;
cin>>quantity;
if (selection = =1)
{ price = quantity * 0.50;}
else if (selection = =2)
{ price = quantity * 0.30;}
else if (selection = =3)
{ price = quantity * 0.20;}
else if (selection = = 4)
{ price = quantity * 0.10;}
else
{ cout <<"invalid selection";}
cout<<"the price is :     "<<price;
return 0;
}
ANSWER:

#include <iostream.h>
main ()
{
int selection,quantity;
float price;
cout<<"1.pen = Rm0.50";
cout<<"2.pencil = Rm0.30";
cout<<"3.ruler = Rm0.20";
cout<<"4.eraser = Rm0.10";
cin>>selection;
cin>>quantity;
switch (selection)
{
case 1: price = quantity * 0.50;break
case 2: price = quantity * 0.30;break
case 3: price = quantity * 0.20;break
case 4: price = quantity * 0.10;break
default: cout<<"invalid selection";
}
cout<<"the price is: "<<price;
return 0;
}

Sunday, March 6, 2011

exercise 1

1) Solve the equestion below solve the following :
a) 5 * 2 % 3 + 25 / 5

b) a = 5 ,b = 6
! ((a<3) && (a = = 3) ll (b > a)
2) identify the syntax errors in the following program
include <iostream.h>
mai ()
{
float allowance = 300.00 salary;
cout <<"input salary = ";
cin >salary;
Tsalary = salary + 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.
nie yg da wat programming:
4)write a program that allowance their average of 5 numbers that can be input by user.
answer:
#include <iostream.h>
main()
{
float no1;
float no2;
float no3;
float no4;
float no5;
float total;
float average;
//input 1
cout <<"num 1";
cin>> no1;
//input 2
cout<<"num 2";
cin>>no2;
//input 3
cout<<"num 3";
cin>>no3;
//input 4
cout<<"num 4";
cin>>no4;
//input 5
cout<<"num 5";
cin>>no5;
//formula
total = no1 + no2 + no 3 + no 4 + no 5
//output
cout <<"total"<<total;
//formula
average = total/5;
//output
cout<<"average"<<average;
return 0;
}

nie yg da jd wat programming

5)write a program that will calculate the area of rectangular,triangle and circle:
answer:
#include <iostream.h>
main ()
{
//declare variable
float height;
float weight;
float area_rectangle;
float radius;
aloat area_circle;
float area_triangle;
//input 1
cout<<"enter height";
cin>>height;
//input 2
cout <<"enter weight";
cin>>weight;
//input 3
cout<<enter radius";
cin>>radius;
//formula 1
area_rectangle = height * width;
//output 1
cout<<"area_rectangle ="<<area_rectangle;
formula 2
area_circle = 3.14 * radius * radius;
//output 2
cout <<"area_circle ="<<area_circle;
//formula 3
area_triangle = 0.5 * height * height;
//output 3
cout<<"area_triangle ="<<area_triangle;
return 0;
}

nie yg da jd wt programming

ok da siap pown...pnt glew wt nie...hehehehe