a) __________Number 1=1
b) __________Number 3=3.0
c) __________Text 1=”1 have a car”
d) __________Huruf = “B”
e) __________AccountNo =”6666666443”
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”
Output:
Jumlah pinjaman: RM16000.00
CGPA yang diperolehi:3.00
Diskaun:RM 12800
Jumlah oinjaman yang perlu dibayar selepas diskaun: RM3200
3. You are required to do a program that will execute the multiply or divide operation.The operation is based on the user’s choice.You must use SWITCH-CASE STATEMENT:
Output.
____________________________________________
MENU PILIHAN
____________________________________________
1.Pendaraban
2.Pembahagian
__________________________________________
Masukkan nombor pertama:4
Masukkan nombor kedua:8
Masukkan pilihan anda:1
Hasil darab 4 8 ialah 32
ANSWER
#include <iostream.h>
main()
{
//Declare variable
int num1,num2,selection,total_multiply,total_divided;
cout<<"masukkan nombor 1=";
cin>>num1;
cout<<"masukkan nombor kedua=";
cin>>num2;
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_divide = num1/num2;
cout<<hasil_bahagi"<<num1<<"dan<<num2<<"ialah"<<total_divide endl:
break
}
return 0;
}
4. Change the algebra expression to anathematic 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
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
ANSWER
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
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;
ANSWER
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
7. Convert the while statement below for statement
int j=10; while (j>0)
{
cout<<" "<
int j;
for(j=10;j>0;j--)
{
cout<<" "<
}
No comments:
Post a Comment