Professional Documents
Culture Documents
Revision Lecture - Past Exam Review
Revision Lecture - Past Exam Review
EP 100 Examinations Review
Exam Structure
• Fundamentals (20 marks)
• Control Flow (20 marks)
• Array and Matrix (20 marks)
• Function and I/O (20 marks)
• Program Development (20 marks)
Note: Not necessarily the same structure for the current exam
Q1a ‐ Fundamentals
70 int factorial=1;
120 for(i=k;i>1;i--)
140 factorial=factorial*i;
Q1c
illegal
illegal
illegal
illegal
legal
Q2a – Control Flow
Loop variables int i = 0;
…
Initialisation for ( i=0; i<9; i++)
{
Termination test …
}
Variable updating
Q2b
#include <stdio.h>
int main()
{
int deposit,withdraw,balance; // 1 marks for variables
return 0;
} Using a Do–While is also acceptable
Q3a – Array and Matrix
#include <stdio.h>
int main()
{
float A[2][2],B[2][2],X[2][2]; // define A, B and X
// 2 marks for all correct definitions
float Anorm[2][2],Bnorm[2][2]; // define the A and B normalised matrix
float determA,determB; // define determinant
int i,j,k;
// 3 marks for correct inputs for A and B
printf("Enter the first row of matrix A :");
scanf("%f %f", &A[0][0],&A[0][1]);
printf("Enter the second row of matrix A :");
scanf("%f %f", &A[1][0],&A[1][1]);
printf("Enter the first row of matrix B :");
scanf("%f %f", &B[0][0],&B[0][1]);
printf("Enter the second row of matrix B :");
scanf("%f %f", &B[1][0],&B[1][1]);
// 2 marks for correct determinant operation
determA = A[0][0]*A[1][1] - A[1][0]*A[0][1];
determB = B[0][0]*B[1][1] - B[1][0]*B[0][1];
return 0;
}
Problem with (iii) is the one of the determinant value could be zero which means
the computation is not valid for this instance. Suggest to check value of determinants
and if any of them is zero, exit the program. // 2 marks
Q3b
for(i=0;i<19;i++)
reverselist[19-i]=list[i];
Q4a – Function and I/O
#include <stdio.h>
float biggest (float, float); // declaration of function
int main()
{
FILE *fp; // variable declaration – 1 marks
int i=0,j,istatus;
float value;
float min,max,avg;
float storage[1000];
#define PI 3.14159
#define g 9.807 // constant definition 1 mark
int main()
{
FILE *fp; // variables declarations 1 mark
float length, period;
float length_start,length_end;
return 0;
}
Q5b
#include <stdio.h>
#include <math.h>
int main()
{
float intensity; // in w/m^3
float L; // in decibel
return 0;
}
continue
L = 10* log10(intensity/I_ref);
return L;
}
return intensity;
}
Loudness to Intensity Conversion
Code Tracing
Code Tracing (Ans)
0
2 1
4 3 2
6 5 4 3
Semester 1, 2013 Exam Scope
• C programming fundamentals
• Control flow
• Looping structure
• Array, matrix and data structure
• Functions
• File IOs
Examination Structure
Question 1 – Fundamentals
Question 2 – Control Flow
Question 3 – Repetition
Question 4 – Arrays and Matrices
Question 5 – Functions and File I/O
Finally
eVALUate is open!
Have your say now!