Académique Documents
Professionnel Documents
Culture Documents
0
INSTRUCTIONS
Do not copy the assignment question and instructions to your answer.
Prepare your assignment answer following the layout of the ASSESSMENT
CRITERIA shown in the RUBRICS provided for the course. Where RUBRICS are
not provided, follow the instructions/guidelines specified by the Open University
Malaysia (OUM) for the assignment concerned.
Your assignment should be written according to the number of words outlined in
the assignment instruction EXCLUDING references.
Type your answer using 12 point Times New Roman font and 1.5 line spacing.
Show the number of words at the end of your assignment.
Tables and figures where provided, should be appropriately titled.
List your references separately in the APPENDIX page.
1
ATTACHMENT
QUESTION 1
You are given a table that shows the assignment and examination marks of CBDS 2103
No 1 2 3 4 5 6 7 8 9 10
Assignment Marks 88 75 92 35 67 77 56 95 63 35
Examination Marks 78 68 95 20 75 65 45 97 82 44
1. Create a 2-D array that will record the student’s assignment and examination marks.
2. Input the assignment and examination marks.
3. Calculate the average assignment and examination marks.
4. Calculate the total assignment and examination marks.
5. Display all of the calculated marks.
2
ANSWER:
/*
OPERATION: CREATE A 2-D ARRAY THAT WILL RECORD THE STUDENT’S ASSIGNMENT
STUDENT ID:880301526953001
*/
#INCLUDE <IOSTREAM>
INT MAIN()
DOUBLE AVERAGE = 0;
COUT<< "HOW MANY ASSIGNMENT SCORE DO YOU WANT TO INPUT" << ENDL;
SCORES_ARRAY[I][1] = I+1;
3
COUT <<" ENTER ASSIGNMENT SCORE " << I+1 << ":";
RETURN 0;
4
OUTPUT:
Second step is choose the assignment score than I choose 5 assignment that it will ask to
key in the marks for assignment 1 until 5 than it will calculate the average all the
assignment marks.
5
QUESTION 2
6
ANSWER :-
/*
COURSE:DATA STRUCTURE
STUDENT ID:880301526953001
*/
#INCLUDE <STDIO.H>
#INCLUDE <MALLOC.H>
#INCLUDE <STDLIB.H>
7
STRUCT NODE {
INT VALUE;
};
VOID INSERT();
VOID DISPLAY();
VOID DEL();
INT COUNT();
INT DATA;
INT MAIN() {
INT OPTION = 0;
PRINTF("\NOPTIONS\N");
8
PRINTF("OTHERS : EXIT()\N");
SCANF("%D", &OPTION);
SWITCH (OPTION) {
CASE 1:
INSERT();
BREAK;
CASE 2:
DEL();
BREAK;
CASE 3:
DISPLAY();
BREAK;
CASE 4:
COUNT();
BREAK;
DEFAULT:
BREAK;
RETURN 0;
//THE PROGR
VOID INSERT() {
SCANF("%D", &DATA);
9
TEMP_NODE = (DATA_NODE *) MALLOC(SIZEOF (DATA_NODE));
TEMP_NODE->VALUE = DATA;
IF (FIRST_NODE == 0) {
FIRST_NODE = TEMP_NODE;
} ELSE {
HEAD_NODE->NEXT = TEMP_NODE;
TEMP_NODE->NEXT = 0;
HEAD_NODE = TEMP_NODE;
FFLUSH(STDIN);
VOID DEL() {
COUNTVALUE = COUNT();
TEMP_NODE = FIRST_NODE;
SCANF("%D", &POS);
IF (POS == 1) {
FIRST_NODE = TEMP_NODE;
10
} ELSE {
WHILE (TEMP_NODE != 0) {
IF (I == (POS - 1)) {
PREV_NODE->NEXT = TEMP_NODE->NEXT;
HEAD_NODE = PREV_NODE;
BREAK;
} ELSE {
I++;
PREV_NODE = TEMP_NODE;
} ELSE
VOID DISPLAY() {
INT COUNT = 0;
TEMP_NODE = FIRST_NODE;
WHILE (TEMP_NODE != 0) {
COUNT++;
11
}
INT COUNT() {
INT COUNT = 0;
TEMP_NODE = FIRST_NODE;
WHILE (TEMP_NODE != 0) {
COUNT++;
RETURN COUNT;
OUTPUT:-
Second step is when we choose option 1,for the option is to insert the linked list then
12
Third step is I choose to display the linked list which that I already insert the value which
13
Fourth is I choose option 2 which is to the delete the linked list so it will pop up the
command which enter position for delete the element.the delete is successfully.
14
Fifth step is I choose the number 4 option to count the linked list than it will display
display the no of item in linked list
15
16
Lastly is exit program,when I enter number 5 the program will terminate and exit cause
number 5 is not in the option.
17