a) int Number 1=1
b) float Number 3=3.0
c) string Text 1=”1 have a car”
d) char Huruf = “B”
e) int AccountNo =”6666666443”
EXERCISE NO 2
#include
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="<
selepas diskaun="<
if ((cgpa>2.99)&&(cgpa<=2.00));
diskaun=jumlah_pinjaman*40/100;
bayaran_pinjaman=jumlah_pinjaman-diskaun;
cout<<"\n Diskaun="<
selepas diskaun="<
if (cgpa=4.00);
diskaun=jumlah_pinjaman*100/100;
bayaran_pinjaman=jumlah_pinjaman-diskaun;
cout<<"\n Diskaun="<
selepas diskaun="<
}
return 0;
}
EXERCISE NO 3
#include
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<
case 2:(selection=2)
total_divided=num1/num2;
cout<
}
return 0;
}
EXERCISE NO 4
i) y=(m-4ax)/79
ii) y=6bc/(45s-2xy)
iii) y=((2+AB+C)/3d)+5xyz
iv) y=(2kb/2ki)-3jb
v) y=xy+x*x-2ab
EXERCISE NO 5
a) m=5
m*=m(3+4)*2
m=5*5(7)*2
m=25*14
m=350
b) m=2
m*=((3*4)1/2)-9
m=2*(12*1/2)-9
m=2*6-9
m=12-9
m=3
EXERCISE NO 6
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";
output:
if(25.12<=2)
var 1 bigger than var 2
b) int n=20;
n/=5;
output:
n=n/5
n=20/5
n=4
EXERCISE NO 7
int j;
for(j=10;j>0;j--)
{
cout<<" "<
EXERCISE NO 8
#include
main()
{
int k;
float P,average;
float total;
k=1 ;
while (k<=4)
{
cout<<"Enter price";
cin>>P;
k++;
}
total=P+P+P+P;
cout<<"\nyour total is"<
cout<<"\nyour average is"<
}
---------------------------------------------------------------------------------------