selepas miss mengajar loop miss memberi latihan individu kerana miss ingin semua students mahir dalam fop. exercise yg diberi adalah.
1. fill in the blank with the appropriate data types for the following variable declaration syntax
a. _________ number 1=1
b. _________ number 3=30
c. _________ text 1=" i have a car"
d. _________ huruf = "b"
e. _________ account no = "6666666443"
2. you are given PTPTN loan with the amount of rm16000. calculate the amount that you should pay other PTPTN discount based on the CGPA. you must use if...else statement
Output
Jumlah pinjaman = rm16.000
CGPA yg diperoleh = 3.00
Diskaun = rm 12.800
#include <iostrean.h>
main()
{
//declare variable
float (cgpa,discount,jumlah_pinjaman,bayaran_pinjaman;
cout<<"jumlah pinjaman=";
cin>>jumlah_pinjaman;
cout<<"cgpa yg diperolehi=";
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 yg perlu dibayar selepas="<<bayaran_pinjaman<<endl;
3. you are required to do program that will execute the multiply or divided operation is based on the user's choice. you must use switch.....case statement
Output:
#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 anthmetic expression
5. solve the statement below to find m value show the working :-
a) m = 5
m* = (3+4) * 2
b) m = 2
m* = ((3*4)1/2)-9
6. find the output for the following segment:-
a) float var 1 = 25.12, var 2 = 15.0;
if (var 1<= var 2) cout<<"var 1 less or same as var 2"; else cout<<"var 1 bigger than var 2";
b) int n = 20; n/= 5;
7.convert the while statement below for statement
int j = 10; while (j>0)
{
8. write of program that needs 4 prices using while loop and calculates the sum of the thing a program must use function while for calculate the average of the price.
#include <iostream.h>
main()
int k;
float P,total,average;
K=1
while(k<=4)
{
cout<<"Enter price"<<K<<"=j;
cin>>P;
ktt; total=total+P;
}
average=total/4;
cout<<"your total is"<<total<<"and average is" average;
return0;
}
Tiada ulasan:
Catat Ulasan