6/12/2013

DCT1063 PROGRAMMING 2

Chapter 1 : POINTER

1.1 Define what is pointer and what is null pointer?
pointer is a variable that holds a memory address

1.2 Consider the following code

int PhoneContact[100];
int *ptr;

(i) Give the statement that makes ptr point to the first element of PhoneContact.
ptr = PhoneContact; or ptr =&PhoneContact[0];
(ii) Give the statement that makes ptr point to the last element of PhoneContact.
ptr = &PhoneContact[99];

1.3 Show output of the * following code: * browser couldnt show a correct symbol

double cpa = 3.2;
double *ptr;
ptr = &cpa; // assume that address of cpa is 001000
cout << cpa << "  " << *ptr;


1.4 What is output of the *following code? * browser couldnt show a correct symbol

int a[10] ={1,2,3,4,5};
int *ptr = a;
cout << a[ 4 ] << " " << *( ptr + 5 ) << " " << ptr[ 6 ];

Chapter 2 : Managing Memory

Consider the following program.




2.1 Briefly explain what the above program do and what is printed.
the program ask user the numbers of random number to generated an stores it into array_num.

2.2 What happen if input for N is more than 100 and what is is your solution?
the array arry_num only can store integer number up to 100 only, The solutions are as follows (pls refer to the program provided in power point slide (chapter chapter 2 : managing memory).

Chapter 3 : FILE INPUT AND FILE OUTPUT

Assume that each of the following statements applies to the same program.

3.1 Write a statement that opens file oldmast.dat for input; use an ifstream object called inOldMaster.
ifstream inOldMaster;
inOldMaster.open("oldmast.dat")

3.2 Write a statement that opens file trans.dat for input; use an ifstream object called inTransaction.


3.3 Write a statement that opens file newmast.dat for output , use ofstream object outNewMaster.
3.4 Write a statement that reads a record from the file oldmast.dat. The record consists of integer accountNumber, string name and  floating-point currentBalance; use ifstream object inOldMaster.


3.5 Write a statement that reads a record from the file TRans.dat. The record consists of integer accountNum and floating-point  RMAmount; use ifstream object inTransaction.


Chapter 4 : STRING

4.1 Briefly explain the purpose of the following functions;strlen(),strcmp(),strcpy() ,tolower(),toupper(),islower(),toupper().

4.2 Show the output of the following code fragments.

(i) cout<
(ii) cout<
(iii) cout<
(iv) cout<


4.3 Show output of the following program if the input is "TATIUC".

Chapter 5: ADVANCED DATA TYPE

<>



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