Showing posts with label 10/11 SEM 2 DCT1063. Show all posts
Showing posts with label 10/11 SEM 2 DCT1063. Show all posts

3/20/2011

DCT1063 QUIZ

QUIZ – ADVANCED DATA TYPE

Write a single statement or a set of statement to accomplish each of the following.


  1. Define a structure called Komputer containing double variable harga and char array model whose values may be as long as 25 characters.

    [3 marks]

struct komputer {

double harga;

char model[25];

};


  1. Declare variable ACER to be of type Komputer and array HP[10] to be of type Komputer.

[3 marks]

struct komputer ACER, HP[10];


  1. Read a PC Price and a PC model from the keyboard into the individual members of variable ACER.

[2 marks]

cin>>ACER.harga;

cin>>ACER.model;



  1. Assign the member values of variable ACER to element 3 of array HP.

[2 marks]

HP[2].harga = ACER.harga;

HP[2].model = ACER.model; //strcpy(HP[2].model, ACER.model);

1/24/2011

DCT1063 P2 : Pointer and Array


A pointer is a variable that contains a memory address. An array is a variable that holds multiple values of the same type. In C++, there is a close relationship between pointers and arrays. In fact, frequently a pointer and an array are interchangeable.


What is output of the code above, why?

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)

1/10/2011

DCT1063 PROGRAMMING 2 Quiz 1

1. Show output of the following C++ program.














Output
A 0x000123C12 // given
B 3
C 0x000123C12
D 3


2. Write a C++ code that declares two pointers to integers. Initialize one to NULL, another to point to the address of int variable x.

int *P1 = NULL;
int *P2 = &n;

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.  ...