Students are required to submit their coursework online using their individual coursework pages on theMosaic website.
Answer all questions. This assessment has a total of 20 marks. Each question will be marked according to the following criteria:
Marks
Criteria
5
Source code uses an effective design to answer the question, compiles without errors and includes informative comments.
4
Source code answers the question, compiles without errors and includes informative comments.
3
Source code answers the question and compiles without errors.
2
Source code is relevant to the question, but does not compile.
1
Source code is incorrect or not relevant to the question.
COURSEWORK QUESTIONS
QUESTION 1
[5 Marks]
Write a C program that accepts 10 input integers. For each input number, display an output message according to its value:
Display message British Airways if the input value is 145
Display message American Airlines if the input value is 245
Display message Singapore Airlines if the input value is 345
Display message Airline not recognized if the input value is not145, 245 or 345
QUESTION 2
[5 Marks]
In the same program as question 1, add a function that accepts an integer input and returns the result based on the following formula:
output = ( input * 20 ) - input
For example, if the input integer was 145, then the function would return 2755 and if the input integer was 45, then the function would return 855.
QUESTION 3
[5 Marks]
In the same program as question 1, add a while loop to iterate through all 10 input integers and display the result of calling the function written for question 2.
QUESTION 4
[5 Marks]
In the same program as question 1, add a for loop to iterate through all 10 input integers and find the lowest number and the highest number. Display an output message to indicate both numbers.
#include <stdio.h>
int calculate(int);
int main(void) { int numbers[10]; int highest, lowest, counter;