SlideShare a Scribd company logo
1 of 12
TK6913 : PROGRAMMING 1
SEMESTER 3, 2004/2005
Name: Mohd Nasir Ahmad Aziz
Matrix No: G71508
ASSIGNMENT 1
1. The following table shows the exchange rates for a number of foreign
currencies:
Singapore Australia UK
SGD 1 = MYR 2.20 AUD 1 = MYR 2.60 UKP 1 = MYR 7.30
a. Calculate the following:
• the amount of Malaysian ringgit that can be obtained for SGD10.00
• the amount of Malaysian ringgit that can be obtained for UKP50.00
b. (*A) Build an algorithm for converting an amount of Singapore dollars to
Malaysian ringgit.
c. (*B) Build an algorithm for converting an amount of Australia dollars to
Malaysian ringgit.
d. (*C) Build an algorithm for converting an amount of UK pound to
Malaysian ringgit.
e. Generalize your algorithm so that it is capable of converting an amount
of any of the foreign currencies in the table given above to Malaysian
ringgit. Use the steps provided in (b) to build the algorithm.
2. A teacher needs to calculate the average marks for her students based on
the marks scored for the three tests given to them.
a. What is the average mark Ahmad will obtain if he scored 45%, 67% and
88% for those tests?
b. Build an algorithm to calculate the average mark obtained by a single
student.
c. Generalize your algorithm so that it is capable of calculating the average
marks for a number of students.
d. (Lab Task) Write your algorithms in CFlow and test them.
1
ANSWERS:
1. a) 1 SGD = 2.2 MYR
10SGD=2.2 * 10 MYR
= 22 MYR
1 UKP = 7.30 MYR
50 UKP=7.30 * 50 MYR
=365 MYR
b)
c)
2
START
INPUT
SGD
MYR  2.3 * SGD
OUTPUT
MYR
END
START
d)
3
INPUT
AUD
MYR  2.6 * AUD
OUTPUT
MYR
END
START
e)
4
INPUT
UKP
MYR  7.30 * SGD
OUTPUT
MYR
END
START
2. a) Average Ahmad = (454 + 67 + 88)/ 3
= 66.67 %
b)
5
INPUT
SGD, AUD, UKP
MYR  (2.3 * SGD) + (2.6 * AUD) + (7.30 * UKP)
OUTPUT
MYR
END
2. c)
6
START
INPUT
Test1, Test2, Test3
Average  (Test1 + Test2 + Test3 )/3
OUTPUT
Average
END
START
INPUT
Mark [ i ]
2. d) Test with C Programming:
#include <stdio.h>
void main() {
int mark[12], i, bil, total_mark;
float Average_mark;
for(i = 0; i < 12; i++){
printf("Enter mark %d : ", i);
scanf("%d", &mark[i]);
}
total_mark= 0;
7
Total Mark  0
Total Mark +  Mark [ i ]
OUTPUT
Average Mark
END
While i <12
Average Mark  Total Mark / 12
for (i = 0; i < 12; i++)
total_mark += mark[i];
Average_mark = (float) total_mark / 12;
bil = 0;
for (i = 0; i < 12; i++ )
if (mark[i] > Average_mark)
bil++;
printf("nAverage mark= %.2f", Average_mark);
}
Output:
Enter mark 0 : 80
Enter mark 1 : 85
Enter mark 2 : 93
Enter mark 3 : 100
Enter mark 4 : 98
Enter mark 5 : 92
Enter mark 6 : 98
Enter mark 7 : 96
Enter mark 8 : 95
Enter mark 9 : 65
Enter mark 10 : 60
Enter mark 11 : 63
Average mark= 85.42
c) Alternative Answer
8
START
INPUT
Mark for Student 1: Test1, Test 2,Test 3
Mark for Student 2: Test1, Test 2,Test 3
Mark for Student 3: Test1, Test 2,Test 3
Mark for Student 4: Test1, Test 2,Test 3
2. d) Test with C Programming: Alternative Answer
/* This Programme compute the Average mark of a number of students in three tests */
#include<stdio.h>
void main(){
int S1T1,S1T2,S1T3,Ave_S1,S2T1,S2T2,S2T3,Ave_S2,S3T1,S3T2,S3T3,Ave_S3,S4T1,
S4T2,S4T3,Ave_S4,Average;
printf("Marks for Student1 in Test1,2,3:n");
scanf("%d %d %d", &S1T1, &S1T2, &S1T3);
printf("Test1:%d, Test2:%d, Test3:%dn", S1T1, S1T2, S1T3);
Ave_S1=(S1T1+S1T2+S1T3)/3;
printf("Print marks for Student2 in Test1,2,3:n");
scanf("%d %d %d",&S2T1,&S2T2,&S2T3);
printf("Test1:%d,Test2:%d,Test3:%dn",S2T1,S2T2,S2T3);
Ave_S2=(S2T1+S2T2+S2T3)/3;
9
Average Student 1  (Test1 + Test2 + Test3 )/3
Average Student 2  (Test1 + Test2 + Test3 )/3
Average Student 3  (Test1 + Test2 + Test3 )/3
Average Student 4  (Test1 + Test2 + Test3 )/3
Average Average Student 1 + Average Student 2 + Average Student 3 +
Average Student 4
OUTPUT
Average
END
printf("Print marks for Student3 in Test1,2,3:n");
scanf("%d %d %d",&S3T1,&S3T2,&S3T3);
printf("Test1:%d,Test2:%d,Test3:%dn",S3T1,S3T2,S3T3);
Ave_S3=(S3T1+S3T2+S3T3)/3;
printf("Print marks for Student4 in Test1,2,3:n");
scanf("%d %d %d",&S4T1,&S4T2,&S4T3);
printf("Test1:%d,Test2:%d,Test3:%dn",S4T1,S4T2,S4T3);
Ave_S4=(S4T1+S4T2+S4T3)/3;
Average=(Ave_S1+Ave_S2+Ave_S3+Ave_S4)/4;
printf("Average:%d",Average);
}
OUTPUT
Marks for Student1 in Test1,2,3:
80 85 93
Test1:80, Test2:85, Test3:93
Print marks for Student2 in Test1,2,3:
100 98 92
Test1:100,Test2:98,Test3:92
Print marks for Student3 in Test1,2,3:
98 96 95
Test1:98,Test2:96,Test3:95
Print marks for Student4 in Test1,2,3:
65 60 63
Test1:65,Test2:60,Test3:63
Average:85
Page 49,Text Book
Question 4:
10
START
INPUT
Kod , Integer X, Integer Y
Z  X + YIf Kod=c
Yes
Question 5: (Page 50,Text Book)
11
OUTPUT
Z
END
Z  X - YIf Kod=c
Z  X * YIf Kod=c
Z  X / YIf Kod=c
Yes
Yes
Yes
No
No
No
No
START
INPUT
Kod Item
Harga 1 30.00 * qIf Kod Item=1
Yes
No
INPUT
Quantity, q
Harga 2  35.00 * qIf Kod Item=2
Yes
INPUT
Quantity, q
12
OUTPUT
Jumlah Harga
END
No
Harga 3  40.00 * qIf Kod Item=3
Yes
No
INPUT
Quantity, q
Harga 4  90.00 * qIf Kod Item=4
Yes
No
INPUT
Quantity, q
Harga 5 120.00 * qIf Kod Item=5
Yes
No
INPUT
Quantity, q
Jumlah Harga  Harga 1 + Harga 2 + Harga 3 + Harga 4 + Harga 5

More Related Content

Similar to Assignment1

Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 sol
IIUM
 
Labsheet2 stud
Labsheet2 studLabsheet2 stud
Labsheet2 stud
rohassanie
 
Benchmarking Perl (Chicago UniForum 2006)
Benchmarking Perl (Chicago UniForum 2006)Benchmarking Perl (Chicago UniForum 2006)
Benchmarking Perl (Chicago UniForum 2006)
brian d foy
 
Dti2143 chapter 3 arithmatic relation-logicalexpression
Dti2143 chapter 3 arithmatic relation-logicalexpressionDti2143 chapter 3 arithmatic relation-logicalexpression
Dti2143 chapter 3 arithmatic relation-logicalexpression
alish sha
 
Buku panduan bacaan untuk sjk(t)
Buku panduan bacaan untuk sjk(t)Buku panduan bacaan untuk sjk(t)
Buku panduan bacaan untuk sjk(t)
Raja Segaran
 
Bti1022 lab sheet 3
Bti1022 lab sheet 3Bti1022 lab sheet 3
Bti1022 lab sheet 3
alish sha
 
#include stdafx.h#include iostream#include string#incl.pdf
#include stdafx.h#include iostream#include string#incl.pdf#include stdafx.h#include iostream#include string#incl.pdf
#include stdafx.h#include iostream#include string#incl.pdf
anonamobilesp
 

Similar to Assignment1 (20)

Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 sol
 
C lab-programs
C lab-programsC lab-programs
C lab-programs
 
CP Handout#9
CP Handout#9CP Handout#9
CP Handout#9
 
Vcs16
Vcs16Vcs16
Vcs16
 
A practical work of matlab
A practical work of matlabA practical work of matlab
A practical work of matlab
 
UNIT 2 LOOP CONTROL.pptx
UNIT 2 LOOP CONTROL.pptxUNIT 2 LOOP CONTROL.pptx
UNIT 2 LOOP CONTROL.pptx
 
Labsheet2
Labsheet2Labsheet2
Labsheet2
 
Programming Fundamentals Arrays and Strings
Programming Fundamentals   Arrays and Strings Programming Fundamentals   Arrays and Strings
Programming Fundamentals Arrays and Strings
 
Labsheet2 stud
Labsheet2 studLabsheet2 stud
Labsheet2 stud
 
Fuzail_File_C.docx
Fuzail_File_C.docxFuzail_File_C.docx
Fuzail_File_C.docx
 
Benchmarking Perl (Chicago UniForum 2006)
Benchmarking Perl (Chicago UniForum 2006)Benchmarking Perl (Chicago UniForum 2006)
Benchmarking Perl (Chicago UniForum 2006)
 
Dti2143 chapter 3 arithmatic relation-logicalexpression
Dti2143 chapter 3 arithmatic relation-logicalexpressionDti2143 chapter 3 arithmatic relation-logicalexpression
Dti2143 chapter 3 arithmatic relation-logicalexpression
 
C++ Programm.pptx
C++ Programm.pptxC++ Programm.pptx
C++ Programm.pptx
 
Junaid program assignment
Junaid program assignmentJunaid program assignment
Junaid program assignment
 
Buku panduan bacaan untuk sjk(t)
Buku panduan bacaan untuk sjk(t)Buku panduan bacaan untuk sjk(t)
Buku panduan bacaan untuk sjk(t)
 
K means clustering
K means clusteringK means clustering
K means clustering
 
C PROGRAMS
C PROGRAMSC PROGRAMS
C PROGRAMS
 
Bti1022 lab sheet 3
Bti1022 lab sheet 3Bti1022 lab sheet 3
Bti1022 lab sheet 3
 
#include stdafx.h#include iostream#include string#incl.pdf
#include stdafx.h#include iostream#include string#incl.pdf#include stdafx.h#include iostream#include string#incl.pdf
#include stdafx.h#include iostream#include string#incl.pdf
 
Automata fix.pdf
Automata fix.pdfAutomata fix.pdf
Automata fix.pdf
 

Recently uploaded

如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
acoha1
 
Displacement, Velocity, Acceleration, and Second Derivatives
Displacement, Velocity, Acceleration, and Second DerivativesDisplacement, Velocity, Acceleration, and Second Derivatives
Displacement, Velocity, Acceleration, and Second Derivatives
23050636
 
1:1原版定制利物浦大学毕业证(Liverpool毕业证)成绩单学位证书留信学历认证
1:1原版定制利物浦大学毕业证(Liverpool毕业证)成绩单学位证书留信学历认证1:1原版定制利物浦大学毕业证(Liverpool毕业证)成绩单学位证书留信学历认证
1:1原版定制利物浦大学毕业证(Liverpool毕业证)成绩单学位证书留信学历认证
ppy8zfkfm
 
edited gordis ebook sixth edition david d.pdf
edited gordis ebook sixth edition david d.pdfedited gordis ebook sixth edition david d.pdf
edited gordis ebook sixth edition david d.pdf
great91
 
原件一样伦敦国王学院毕业证成绩单留信学历认证
原件一样伦敦国王学院毕业证成绩单留信学历认证原件一样伦敦国王学院毕业证成绩单留信学历认证
原件一样伦敦国王学院毕业证成绩单留信学历认证
pwgnohujw
 
1:1原版定制伦敦政治经济学院毕业证(LSE毕业证)成绩单学位证书留信学历认证
1:1原版定制伦敦政治经济学院毕业证(LSE毕业证)成绩单学位证书留信学历认证1:1原版定制伦敦政治经济学院毕业证(LSE毕业证)成绩单学位证书留信学历认证
1:1原版定制伦敦政治经济学院毕业证(LSE毕业证)成绩单学位证书留信学历认证
dq9vz1isj
 
Abortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotec
Abortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotecAbortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotec
Abortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotec
Abortion pills in Riyadh +966572737505 get cytotec
 
obat aborsi Banjarmasin wa 082135199655 jual obat aborsi cytotec asli di Ban...
obat aborsi Banjarmasin wa 082135199655 jual obat aborsi cytotec asli di  Ban...obat aborsi Banjarmasin wa 082135199655 jual obat aborsi cytotec asli di  Ban...
obat aborsi Banjarmasin wa 082135199655 jual obat aborsi cytotec asli di Ban...
siskavia95
 
原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证
原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证
原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证
pwgnohujw
 
如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证
acoha1
 
NO1 Best Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialist I...
NO1 Best Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialist I...NO1 Best Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialist I...
NO1 Best Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialist I...
Amil baba
 

Recently uploaded (20)

如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(UPenn毕业证书)宾夕法尼亚大学毕业证成绩单本科硕士学位证留信学历认证
 
Displacement, Velocity, Acceleration, and Second Derivatives
Displacement, Velocity, Acceleration, and Second DerivativesDisplacement, Velocity, Acceleration, and Second Derivatives
Displacement, Velocity, Acceleration, and Second Derivatives
 
Statistics Informed Decisions Using Data 5th edition by Michael Sullivan solu...
Statistics Informed Decisions Using Data 5th edition by Michael Sullivan solu...Statistics Informed Decisions Using Data 5th edition by Michael Sullivan solu...
Statistics Informed Decisions Using Data 5th edition by Michael Sullivan solu...
 
1:1原版定制利物浦大学毕业证(Liverpool毕业证)成绩单学位证书留信学历认证
1:1原版定制利物浦大学毕业证(Liverpool毕业证)成绩单学位证书留信学历认证1:1原版定制利物浦大学毕业证(Liverpool毕业证)成绩单学位证书留信学历认证
1:1原版定制利物浦大学毕业证(Liverpool毕业证)成绩单学位证书留信学历认证
 
Credit Card Fraud Detection: Safeguarding Transactions in the Digital Age
Credit Card Fraud Detection: Safeguarding Transactions in the Digital AgeCredit Card Fraud Detection: Safeguarding Transactions in the Digital Age
Credit Card Fraud Detection: Safeguarding Transactions in the Digital Age
 
edited gordis ebook sixth edition david d.pdf
edited gordis ebook sixth edition david d.pdfedited gordis ebook sixth edition david d.pdf
edited gordis ebook sixth edition david d.pdf
 
原件一样伦敦国王学院毕业证成绩单留信学历认证
原件一样伦敦国王学院毕业证成绩单留信学历认证原件一样伦敦国王学院毕业证成绩单留信学历认证
原件一样伦敦国王学院毕业证成绩单留信学历认证
 
Identify Rules that Predict Patient’s Heart Disease - An Application of Decis...
Identify Rules that Predict Patient’s Heart Disease - An Application of Decis...Identify Rules that Predict Patient’s Heart Disease - An Application of Decis...
Identify Rules that Predict Patient’s Heart Disease - An Application of Decis...
 
1:1原版定制伦敦政治经济学院毕业证(LSE毕业证)成绩单学位证书留信学历认证
1:1原版定制伦敦政治经济学院毕业证(LSE毕业证)成绩单学位证书留信学历认证1:1原版定制伦敦政治经济学院毕业证(LSE毕业证)成绩单学位证书留信学历认证
1:1原版定制伦敦政治经济学院毕业证(LSE毕业证)成绩单学位证书留信学历认证
 
Abortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotec
Abortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotecAbortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotec
Abortion pills in Riyadh Saudi Arabia (+966572737505 buy cytotec
 
社内勉強会資料_Object Recognition as Next Token Prediction
社内勉強会資料_Object Recognition as Next Token Prediction社内勉強会資料_Object Recognition as Next Token Prediction
社内勉強会資料_Object Recognition as Next Token Prediction
 
NOAM AAUG Adobe Summit 2024: Summit Slam Dunks
NOAM AAUG Adobe Summit 2024: Summit Slam DunksNOAM AAUG Adobe Summit 2024: Summit Slam Dunks
NOAM AAUG Adobe Summit 2024: Summit Slam Dunks
 
Jual Obat Aborsi Bandung (Asli No.1) Wa 082134680322 Klinik Obat Penggugur Ka...
Jual Obat Aborsi Bandung (Asli No.1) Wa 082134680322 Klinik Obat Penggugur Ka...Jual Obat Aborsi Bandung (Asli No.1) Wa 082134680322 Klinik Obat Penggugur Ka...
Jual Obat Aborsi Bandung (Asli No.1) Wa 082134680322 Klinik Obat Penggugur Ka...
 
Seven tools of quality control.slideshare
Seven tools of quality control.slideshareSeven tools of quality control.slideshare
Seven tools of quality control.slideshare
 
obat aborsi Banjarmasin wa 082135199655 jual obat aborsi cytotec asli di Ban...
obat aborsi Banjarmasin wa 082135199655 jual obat aborsi cytotec asli di  Ban...obat aborsi Banjarmasin wa 082135199655 jual obat aborsi cytotec asli di  Ban...
obat aborsi Banjarmasin wa 082135199655 jual obat aborsi cytotec asli di Ban...
 
Genuine love spell caster )! ,+27834335081) Ex lover back permanently in At...
Genuine love spell caster )! ,+27834335081)   Ex lover back permanently in At...Genuine love spell caster )! ,+27834335081)   Ex lover back permanently in At...
Genuine love spell caster )! ,+27834335081) Ex lover back permanently in At...
 
Formulas dax para power bI de microsoft.pdf
Formulas dax para power bI de microsoft.pdfFormulas dax para power bI de microsoft.pdf
Formulas dax para power bI de microsoft.pdf
 
原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证
原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证
原件一样(UWO毕业证书)西安大略大学毕业证成绩单留信学历认证
 
如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证
 
NO1 Best Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialist I...
NO1 Best Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialist I...NO1 Best Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialist I...
NO1 Best Kala Jadu Expert Specialist In Germany Kala Jadu Expert Specialist I...
 

Assignment1

  • 1. TK6913 : PROGRAMMING 1 SEMESTER 3, 2004/2005 Name: Mohd Nasir Ahmad Aziz Matrix No: G71508 ASSIGNMENT 1 1. The following table shows the exchange rates for a number of foreign currencies: Singapore Australia UK SGD 1 = MYR 2.20 AUD 1 = MYR 2.60 UKP 1 = MYR 7.30 a. Calculate the following: • the amount of Malaysian ringgit that can be obtained for SGD10.00 • the amount of Malaysian ringgit that can be obtained for UKP50.00 b. (*A) Build an algorithm for converting an amount of Singapore dollars to Malaysian ringgit. c. (*B) Build an algorithm for converting an amount of Australia dollars to Malaysian ringgit. d. (*C) Build an algorithm for converting an amount of UK pound to Malaysian ringgit. e. Generalize your algorithm so that it is capable of converting an amount of any of the foreign currencies in the table given above to Malaysian ringgit. Use the steps provided in (b) to build the algorithm. 2. A teacher needs to calculate the average marks for her students based on the marks scored for the three tests given to them. a. What is the average mark Ahmad will obtain if he scored 45%, 67% and 88% for those tests? b. Build an algorithm to calculate the average mark obtained by a single student. c. Generalize your algorithm so that it is capable of calculating the average marks for a number of students. d. (Lab Task) Write your algorithms in CFlow and test them. 1
  • 2. ANSWERS: 1. a) 1 SGD = 2.2 MYR 10SGD=2.2 * 10 MYR = 22 MYR 1 UKP = 7.30 MYR 50 UKP=7.30 * 50 MYR =365 MYR b) c) 2 START INPUT SGD MYR  2.3 * SGD OUTPUT MYR END START
  • 3. d) 3 INPUT AUD MYR  2.6 * AUD OUTPUT MYR END START
  • 4. e) 4 INPUT UKP MYR  7.30 * SGD OUTPUT MYR END START
  • 5. 2. a) Average Ahmad = (454 + 67 + 88)/ 3 = 66.67 % b) 5 INPUT SGD, AUD, UKP MYR  (2.3 * SGD) + (2.6 * AUD) + (7.30 * UKP) OUTPUT MYR END
  • 6. 2. c) 6 START INPUT Test1, Test2, Test3 Average  (Test1 + Test2 + Test3 )/3 OUTPUT Average END START INPUT Mark [ i ]
  • 7. 2. d) Test with C Programming: #include <stdio.h> void main() { int mark[12], i, bil, total_mark; float Average_mark; for(i = 0; i < 12; i++){ printf("Enter mark %d : ", i); scanf("%d", &mark[i]); } total_mark= 0; 7 Total Mark  0 Total Mark +  Mark [ i ] OUTPUT Average Mark END While i <12 Average Mark  Total Mark / 12
  • 8. for (i = 0; i < 12; i++) total_mark += mark[i]; Average_mark = (float) total_mark / 12; bil = 0; for (i = 0; i < 12; i++ ) if (mark[i] > Average_mark) bil++; printf("nAverage mark= %.2f", Average_mark); } Output: Enter mark 0 : 80 Enter mark 1 : 85 Enter mark 2 : 93 Enter mark 3 : 100 Enter mark 4 : 98 Enter mark 5 : 92 Enter mark 6 : 98 Enter mark 7 : 96 Enter mark 8 : 95 Enter mark 9 : 65 Enter mark 10 : 60 Enter mark 11 : 63 Average mark= 85.42 c) Alternative Answer 8 START INPUT Mark for Student 1: Test1, Test 2,Test 3 Mark for Student 2: Test1, Test 2,Test 3 Mark for Student 3: Test1, Test 2,Test 3 Mark for Student 4: Test1, Test 2,Test 3
  • 9. 2. d) Test with C Programming: Alternative Answer /* This Programme compute the Average mark of a number of students in three tests */ #include<stdio.h> void main(){ int S1T1,S1T2,S1T3,Ave_S1,S2T1,S2T2,S2T3,Ave_S2,S3T1,S3T2,S3T3,Ave_S3,S4T1, S4T2,S4T3,Ave_S4,Average; printf("Marks for Student1 in Test1,2,3:n"); scanf("%d %d %d", &S1T1, &S1T2, &S1T3); printf("Test1:%d, Test2:%d, Test3:%dn", S1T1, S1T2, S1T3); Ave_S1=(S1T1+S1T2+S1T3)/3; printf("Print marks for Student2 in Test1,2,3:n"); scanf("%d %d %d",&S2T1,&S2T2,&S2T3); printf("Test1:%d,Test2:%d,Test3:%dn",S2T1,S2T2,S2T3); Ave_S2=(S2T1+S2T2+S2T3)/3; 9 Average Student 1  (Test1 + Test2 + Test3 )/3 Average Student 2  (Test1 + Test2 + Test3 )/3 Average Student 3  (Test1 + Test2 + Test3 )/3 Average Student 4  (Test1 + Test2 + Test3 )/3 Average Average Student 1 + Average Student 2 + Average Student 3 + Average Student 4 OUTPUT Average END
  • 10. printf("Print marks for Student3 in Test1,2,3:n"); scanf("%d %d %d",&S3T1,&S3T2,&S3T3); printf("Test1:%d,Test2:%d,Test3:%dn",S3T1,S3T2,S3T3); Ave_S3=(S3T1+S3T2+S3T3)/3; printf("Print marks for Student4 in Test1,2,3:n"); scanf("%d %d %d",&S4T1,&S4T2,&S4T3); printf("Test1:%d,Test2:%d,Test3:%dn",S4T1,S4T2,S4T3); Ave_S4=(S4T1+S4T2+S4T3)/3; Average=(Ave_S1+Ave_S2+Ave_S3+Ave_S4)/4; printf("Average:%d",Average); } OUTPUT Marks for Student1 in Test1,2,3: 80 85 93 Test1:80, Test2:85, Test3:93 Print marks for Student2 in Test1,2,3: 100 98 92 Test1:100,Test2:98,Test3:92 Print marks for Student3 in Test1,2,3: 98 96 95 Test1:98,Test2:96,Test3:95 Print marks for Student4 in Test1,2,3: 65 60 63 Test1:65,Test2:60,Test3:63 Average:85 Page 49,Text Book Question 4: 10 START INPUT Kod , Integer X, Integer Y Z  X + YIf Kod=c Yes
  • 11. Question 5: (Page 50,Text Book) 11 OUTPUT Z END Z  X - YIf Kod=c Z  X * YIf Kod=c Z  X / YIf Kod=c Yes Yes Yes No No No No START INPUT Kod Item Harga 1 30.00 * qIf Kod Item=1 Yes No INPUT Quantity, q Harga 2  35.00 * qIf Kod Item=2 Yes INPUT Quantity, q
  • 12. 12 OUTPUT Jumlah Harga END No Harga 3  40.00 * qIf Kod Item=3 Yes No INPUT Quantity, q Harga 4  90.00 * qIf Kod Item=4 Yes No INPUT Quantity, q Harga 5 120.00 * qIf Kod Item=5 Yes No INPUT Quantity, q Jumlah Harga  Harga 1 + Harga 2 + Harga 3 + Harga 4 + Harga 5