Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
142 views2 pages

CS214 - Programming Fundamentals: Quiz 2

1) The document is a quiz for a programming fundamentals course assessing knowledge of pointers and structures. 2) It provides sample code and asks the student to apply their knowledge of pointers to trace the code and fill in the outputs. 3) The student is instructed to use their own student ID number in place of variables and addresses in the code tracing.

Uploaded by

Nomi Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
142 views2 pages

CS214 - Programming Fundamentals: Quiz 2

1) The document is a quiz for a programming fundamentals course assessing knowledge of pointers and structures. 2) It provides sample code and asks the student to apply their knowledge of pointers to trace the code and fill in the outputs. 3) The student is instructed to use their own student ID number in place of variables and addresses in the code tracing.

Uploaded by

Nomi Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Student ID: Section: Name:

CS214 – Programming Fundamentals


Quiz 2
Spring 2021

Time Allowed: 20 Minutes 2 April 2021 Maximum Marks = 10


The use of mobile phones and any other helping material is strictly forbidden

CLO No. CLO Statement Domain Taxonomy Level


2 Write C++ programs that employ the use of pointers, and structures (records). Cognitive 3

Question Number 3 (CLO 2) [10 Marks]


Details of your student ID will be used while answering this question.

4th 3rd 2nd 1st


Digit Digit Digit Digit

X X F - D4 D3 D2 D1

For example, if your student ID is 20F-0318, then D1 = 8, D2 = 8, D3 = 3 and D4 = 0. And you will use 0318 as your student ID.
Apply the concept of pointers to write the output of the following code. All the instructions will be executed in sequence and there are no syntax errors.
Suppose that:
 The array element with index 2 is stored at the address 0x22fe38
 The variable “a” is stored at address = your student ID.
Address Stored in
Code Line Contents of Array Reason/Explanation
Pointer

{D1, D2, D3, D4}


int arr[4]={D1, D2, D3, D4}; Garbage Write the values of D1, D2,
D3, and D4

int a = 5; Garbage

int *ptr = &a; 0 x your ID


Write your id here

ptr = &arr[0];

*ptr = 12;

++ptr;

*ptr = *ptr + 5;

ptr = ptr + 1;

*(++ptr) = 40;

ptr = arr;

*(ptr+4) = 60;

++(*ptr);

ptr = ptr + 4;

You might also like