
SKEE1103-Test 2 Subjective Questions
Authored by Jasmine Hau Yuan Wen
Computers
University
Used 9+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
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;
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
15 questions
Computer Applications in Banking and Finance Quiz
Quiz
•
University
10 questions
Node.js
Quiz
•
University
10 questions
Software Testing
Quiz
•
University
10 questions
Hệ Điều Hành Của Máy Tính
Quiz
•
10th Grade - University
10 questions
C++ Array Quiz
Quiz
•
University
10 questions
Microsoft Word
Quiz
•
University
17 questions
Đề ôn tập cuối HKI lớp 5
Quiz
•
6th Grade - University
15 questions
quiz pertemuan 2 asik ddp
Quiz
•
University
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
10 questions
Probability Practice
Quiz
•
4th Grade
15 questions
Probability on Number LIne
Quiz
•
4th Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
6 questions
Appropriate Chromebook Usage
Lesson
•
7th Grade
10 questions
Greek Bases tele and phon
Quiz
•
6th - 8th Grade
Discover more resources for Computers
12 questions
IREAD Week 4 - Review
Quiz
•
3rd Grade - University
20 questions
Endocrine System
Quiz
•
University
7 questions
Renewable and Nonrenewable Resources
Interactive video
•
4th Grade - University
30 questions
W25: PSYCH 250 - Exam 2 Practice
Quiz
•
University
5 questions
Inherited and Acquired Traits of Animals
Interactive video
•
4th Grade - University
20 questions
Implicit vs. Explicit
Quiz
•
6th Grade - University
7 questions
Comparing Fractions
Interactive video
•
1st Grade - University
38 questions
Unit 8 Review - Absolutism & Revolution
Quiz
•
10th Grade - University