
SKEE1103-Test 2 Subjective Questions

Quiz
•
Computers
•
University
•
Easy

Jasmine Hau Yuan Wen
Used 9+ times
FREE Resource
12 questions
Show all answers
1.
OPEN ENDED QUESTION
3 mins • 1 pt
The scope of a variable can be defined as the accessibility of a variable in the program. Referring to the Figure 1, determine the program execution output of the C code. (10 marks)
Evaluate responses using AI:
OFF
Answer explanation
Num1 = 1
Num2 = 1
Num1 = 2
Num2 = 2
Num1 = 5
2.
OPEN ENDED QUESTION
3 mins • 1 pt
An array is defined as the collection of similar type of data items stored at contiguous memory locations. The C program shown in Figure 2 has an array consists of six (6) elements.
a) The C code in line 4 seems to be incorrect. Rewrite the correct C code in line 4. (2 marks)
b) Determine the output of line 6. (2 marks)
c) Complete the C code in line 10 to display array element values using the for loop. (2 marks)
d) Determine the output of line 10 to incorporate changes in Q2(c). (2 marks)
e) Assuming the integer data type is 32-bit, determine the output of line 13. (2 marks)
Evaluate responses using AI:
OFF
Answer explanation
a) int arr[6] = { 2, 7, 3, 1, 5, 9 };
b) 15
c) printf ("%d\t", arr[i]);
d) 2 7 3 1 5
e) 24
3.
OPEN ENDED QUESTION
3 mins • 1 pt
Structure is a way to group several related variables in various data types into one place. Ali is trying to create a C code with structure as shown in Figure 3 but encountered compilation error. By using the code line number, identify at least five (5) incorrect statements in the program and provide the correct answers.
(Note: You may use a table to answer this question.) (10 marks)
Evaluate responses using AI:
OFF
Answer explanation
4.
OPEN ENDED QUESTION
3 mins • 1 pt
Functions are used to perform certain actions, and they are important for program modularity and code reusability. By referring to the C code shown in Figure 4, answer the following questions.
a) Complete the ‘Function Declaration’ in line 2. (3 marks)
b) State the correct ‘Function Call’ in line 8. (3 marks)
c) Which lines of code is the ‘Function Definition’ of the program? (2 marks)
d) In line 15, the ‘return c’ statement returns the addition value of ‘a + b’ to which line of code? (2 marks)
Evaluate responses using AI:
OFF
Answer explanation
a) int add(int a, int b);
b) Ans: add_result = add (a, b);
c) Line 10-16
d) line 8 (call function)
5.
OPEN ENDED QUESTION
3 mins • 1 pt
Union is a special data type in C that allows to store different data types in the same memory location. By referring to the C code shown in Figure 5, answer the following questions.
a) Declare a variable named ‘Var’ in line 10 with union data type of ‘Data’. (2 marks)
b) Assign a value of 55 and 10.5 to the union member of ‘Var’ as declared in lines 3 and 4, respectively. (4 marks)
c) Determine the output of line 12. (2 marks)
d) Given the following line code, determine the output value of ‘Sat’. (2 marks)
enum week{Mon = 0, Tue, Wed, Thur=4, Fri, Sat, Sun};
Evaluate responses using AI:
OFF
Answer explanation
a) union Data Var;
b) Var.i = 55, Var.f = 10.5;
c) 10
d) Output value at ‘Sat’ = 6
6.
OPEN ENDED QUESTION
3 mins • 1 pt
Array is a compound data type in C program which can store and process multi-dimensional data.
a) Declare a single dimension of floating point array, named ECG_sample, which could store total of 1000 data.
b) Declare a 2-dimension array, named A, with size and value as shown in below:
c) Write a C code segment to sum up only the 2nd column value, which is {2, 5, 8} in matrix A using single for loop only.
Evaluate responses using AI:
OFF
Answer explanation
a) float ECG_sample[1000];
b) int A[3][3] = {1,2,3,4,5,6,7,8,9};
c) int i = 0, sum = 0;
for (i=0, i<3, i++)
{
sum+=A[i][1];
}
7.
OPEN ENDED QUESTION
3 mins • 1 pt
Structure is another user defined data type available in C that allows combination of data items from different datatype and usually used to represent a record. [10 marks]
a) Define a structure data type, named patient_record where it consists of three data members, one is name with character array that could store 30 alphabets, one is age with integer datatype, and another one is treatment_cost with float datatype. [5 marks]
b) Declare an array of structure patient_record, named Wad11, which could store total of 50 patient records. [2 marks]
c) Assume that now for the 10th record of Wad11, you want to update the elements of name to
P. Ramlee, age to 80, and treatment_cost to 3200.00. Write the C code segment to perform this value assignment.
Evaluate responses using AI:
OFF
Answer explanation
a) struct patient_record
{
char name[30];
int age;
float treatment_cost;
};
b) struct patient_record Wad11[50];
c) strcpy(Wad11 [9].name, "P. Ramlee");
Wad11 [9].age = 80;
Wad11 [9].treatment_cost = 3200.00;
Create a free account and access millions of resources
Similar Resources on Wayground
15 questions
Coding club Summit Online Quiz

Quiz
•
University
13 questions
Principles of Programming

Quiz
•
KG - University
10 questions
C#.net test 1

Quiz
•
University
10 questions
BASIC PROGRAMMING QUIZ by Group 5

Quiz
•
University
15 questions
CODE ZENITH

Quiz
•
University
16 questions
PAP Module-3 Part-2

Quiz
•
University
10 questions
Object Oriented Programming

Quiz
•
University
11 questions
oop_r1

Quiz
•
University
Popular Resources on Wayground
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
9/11 Experience and Reflections

Interactive video
•
10th - 12th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
9 questions
Tips & Tricks

Lesson
•
6th - 8th Grade
Discover more resources for Computers
21 questions
Spanish-Speaking Countries

Quiz
•
6th Grade - University
20 questions
Levels of Measurements

Quiz
•
11th Grade - University
7 questions
Common and Proper Nouns

Interactive video
•
4th Grade - University
12 questions
Los numeros en español.

Lesson
•
6th Grade - University
7 questions
PC: Unit 1 Quiz Review

Quiz
•
11th Grade - University
7 questions
Supporting the Main Idea –Informational

Interactive video
•
4th Grade - University
12 questions
Hurricane or Tornado

Quiz
•
3rd Grade - University
7 questions
Enzymes (Updated)

Interactive video
•
11th Grade - University