mcm biasa class mule plul 10 pgi...
Pn. suruh siapkan semua Outcome
& sume latihan yg pnah dibuat dalam class
sblum ni... & msukkn dlm blog... & Pn.
suh submit sblum kul 1pm...
akhir nyer,.. smue nyer aq da bjya siapkan...
Tuesday, March 29, 2011
Exercises no 1
Fill in the blank with appropriate data type for the
following variables declaration syntax :-
a) Numerik (Integer) Number 1=1
b) Numerik (Nombor Nyata) Number 3=3.0
c) Bukan Numerik (Rentetan)Text 1=”1 have a car”
d) Bukan Numerik (Aksara) Huruf = “B”
e) Bukan Numerik (Rentetan) AccountNo =”6666666443”
Exercises no 2
Answer:
#include <iostream.h>
main ()
{
float cgpa,diskaun,jumlah_pinjaman,bayaran_pinjaman;
cout<<"Jumlah pinjaman";
cin>>jumlah_pinjaman;
cout<<"CGPA yang diperolah:";
cin>>cgpa;
if ((cgpa>=3.99)&&(cgpa<=3.00));
diskaun=jumlah_pinjaman*80/100;
bayaran_pinjaman=jumlah_pinjaman-diskaun;
cout<<"\n Diskaun="<<diskaun<<endl;
cout<<"Jumlah pinjaman yang perlu dibayar
selepas diskaun="<<bayaran_pinjaman<<endl;
if ((cgpa>2.99)&&(cgpa<=2.00));
diskaun=jumlah_pinjaman*40/100;
bayaran_pinjaman=jumlah_pinjaman-diskaun;
cout<<"\n Diskaun="<<diskaun<<endl;
cout<<"Jumlah pinjaman yang perlu dibayar
selepas diskaun="<<bayaran_pinjaman<<endl;
if (cgpa=4.00);
diskaun=jumlah_pinjaman*100/100;
bayaran_pinjaman=jumlah_pinjaman-diskaun;
cout<<"\n Diskaun="<<diskaun<<endl;
cout<<"Jumlah pinjaman yang perlu dibayar
selepas diskaun="<<bayaran_pinjaman<<endl;
}
return 0;
}
Exercises no 3
you are required to do program that will execute the multiply
or divided operation is based on the user's choice. You
must see Switch...Case statement Output:
Answer:
#include <iostream.h>
main ()
{
//Declare variable
int num1,num2,selection,total_multiply,total_divided;
cout<<"masukkan nombor satu";
cin>>num1;
cout<<"masukkan nombor dua";
cin>>num 2;
cout<<"masukkan pilihan anda";
cin>>selection;
Switch(selection)
{
case 1:(selection=1)
total_multiply=num1*num2;
cout<<hasil darab"<<num1<<"dan<<num2<<"
ialah"<<total_multiply endl;
break;
case 2:(selection=2)
total_divided=num1/num2;
cout<<hasil_bahagi"<<num<<"dan<<num2<<"
ialah"<<total_divide endl;
break;
}
return 0;
}
or divided operation is based on the user's choice. You
must see Switch...Case statement Output:
Answer:
#include <iostream.h>
main ()
{
//Declare variable
int num1,num2,selection,total_multiply,total_divided;
cout<<"masukkan nombor satu";
cin>>num1;
cout<<"masukkan nombor dua";
cin>>num 2;
cout<<"masukkan pilihan anda";
cin>>selection;
Switch(selection)
{
case 1:(selection=1)
total_multiply=num1*num2;
cout<<hasil darab"<<num1<<"dan<<num2<<"
ialah"<<total_multiply endl;
break;
case 2:(selection=2)
total_divided=num1/num2;
cout<<hasil_bahagi"<<num<<"dan<<num2<<"
ialah"<<total_divide endl;
break;
}
return 0;
}
Exercises no 4
Change the algebra expression to anthmetics expression
Answer:
a) y=(m-4ax)/79
b) y=6bc/(45s-2xy)
c) y=((2+AB+C)/3d)+5xyz
d) y=(2kb/2ki)-3jb
e) y=xy+x*x-2ab
Answer:
a) y=(m-4ax)/79
b) y=6bc/(45s-2xy)
c) y=((2+AB+C)/3d)+5xyz
d) y=(2kb/2ki)-3jb
e) y=xy+x*x-2ab
Exercises no 5
Solve the statement below to find m value show the working:-
a) m=5
m*=m(3+4)*2
b) m=2
m*=((3*4)1/2)-9
a) m=5
m*=m(3+4)*2
b) m=2
m*=((3*4)1/2)-9
Exercises no 6
Find the output for the following segment:-
a) float var 1=25.12, var 2=15.0;
if (var 1<=2)cout<<"var1 less or same as var2";
else cout<<"var1 bigger than var2";
b) in n=20; n/=5;
a) float var 1=25.12, var 2=15.0;
if (var 1<=2)cout<<"var1 less or same as var2";
else cout<<"var1 bigger than var2";
b) in n=20; n/=5;
Exercises no 7
Convert the while statement below for statement
int j=10; while (j>0)
{
cout<<" "<<j
J--J
}
int j=10; while (j>0)
{
cout<<" "<<j
J--J
}
Exercises no 8
Write of program that needs 4 prices using while loop
and calculate the sum of the thing a program must
use function while for calculate the average of the
prices.
#include <iostream.h>
main ()
{
int k;
float P,total,average;
K=1
while (k<=4)
{
cout<<"Enter price"<<K<<"=j;
cin>>P;
k++; total=total+P;
}
average=total/4;
cout<<"your total is"<<total<<"and average is"average;
return 0;
}
Subscribe to:
Posts (Atom)