SKEE1103-Test 2 Subjective Questions

SKEE1103-Test 2 Subjective Questions

University

12 Qs

quiz-placeholder

Similar activities

Tableau Public #1 - Data Source and Familiarization

Tableau Public #1 - Data Source and Familiarization

University

8 Qs

Intro - Comp Thinking, Programming

Intro - Comp Thinking, Programming

University

12 Qs

SatPy

SatPy

University - Professional Development

10 Qs

NME Quiz 1

NME Quiz 1

University

10 Qs

ARRAYS AND FUNCTIONS

ARRAYS AND FUNCTIONS

University

15 Qs

Python - Year 8

Python - Year 8

3rd Grade - University

10 Qs

Array Quiz 2

Array Quiz 2

University

10 Qs

Mobile application test no 1

Mobile application test no 1

University

16 Qs

SKEE1103-Test 2 Subjective Questions

SKEE1103-Test 2 Subjective Questions

Assessment

Quiz

Computers

University

Easy

Created by

Jasmine Hau Yuan Wen

Used 9+ times

FREE Resource

12 questions

Show all answers

1.

OPEN ENDED QUESTION

3 mins • 1 pt

Media Image

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

Media Image

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

Media Image

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

Line 3: struct UTM

Line 7: };

Line 9: struct UTM a;

Line 10: strcpy(a.name, "C program");

Line 11: a.code = 2033;

Line 12: printf("%s", a.name);

Line 13: printf(“%d”, a.code);

4.

OPEN ENDED QUESTION

3 mins • 1 pt

Media Image

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

Media Image

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

Media Image

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

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?