HND Computer Science II Data Structures and Algorithm
HND Computer Science II Data Structures and Algorithm
QUESTION 3
1 The asterick is used together with forward slash as a comment
2 is also used to declare a pointer
3 Is used as multiplication operator
QUESTION 4
50 60 70
500 300 140
QUESTION 5
Not answered.........
QUESTION 6
The pointer ptr will now hold the address of 12010.
QUESTION 7
A) Is valid
B) Is valid
C) Is valid
D) Is valid
E) Is valid
QUESTION 8
A) Is valid
B) Is invalid because of the comma.
C) Is valid
D) Is invalid because of the comma
E) Is valid
QUESTION 9.
A. True
B. False
C. True
D. False
10. proper way to call the following function in order to negate the
void makeNegative(int *val)
{
if(*val > 0)
*val = -(*val);
}
int num = 7;
makeNegative(&num);
cout << num<< endl;
QUESTION 12.
int * ip = new int;
// ...
delete ip;
QUESTION 13.
int * ip;
ip = new int[500];
for(int i = 0; i < 500; i++)
*(ip + i) = 255;
delete [] ip;
QUESTION 14.
a.
#include <iostream>
using namespace std;
int main ()
{
int *ptr = NULL;
cout << "The value of ptr is " << ptr ;
return 0;
}
int value;
a::a(int val) {
value = val;
}
a* clone() {
a* ret = new a(value);
return ret;
}
};