1/22/2011

DCT 1063 ASSIGNMENT 1

1. Answer each of the following. Assume that integer numbers are stored in 4 bytes, and that starting address of the array is at location 1000 in memory. Each part of question should use the result of previous part where appropriate. [20 marks]


  1. Declare an array of type integer called numbers with 10 elements, and initialize the element to the values 1,2,3,4,5,6,7,8,9,10,

[2 marks]

  1. Declare a pointer Ptr that points to an object of type integer.

[2 marks]

  1. Print the element of array numbers using array subscript notation. Use looping structure (for/while/do..while) and assume the integer control variable i has been declared.

[5 marks]

  1. Assign the starting address of array numbers to the pointer variable Ptr.

[2 marks]

  1. Print the element of array numbers using pointer with the pointer
    Ptr. Use looping structure (for/while/do..while) and assume the integer control variable i has been declared.

[5 marks]

  1. Assuming that Ptr points to the beginning of array numbers, what address is referenced by nPtr + 9? What value is stored at that location?

[2 marks]

  1. Assuming that Ptr points to the numbers[8], what address is referenced by nPtr -= 4? What value is stored at that location?

[2 marks]

2. Assume that each of the following statements applies to the same program. ( 10 marks)


a) Write a program that prompts user to enter:-


  1. Name
  2. Matric
  3. Course
  4. CPA


b) Read the data above (a) and write into a file named student.txt as follows.


Name : Ahmad Ashraaf

Matric: 09A04035

Course: CIS

CPA: 3.6


3. Write a program that reads student.txt (as created in 3 b), display its content to screen. (10 Marks)

No comments:

Cara download Installer windows 10 dalam format ISO

1. Jika anda bercadang untuk download windows 10 melalui website rasmi windows - pilihan untuk download dalam format ISO tidak di berikan.  ...