00 Examinations
00 Examinations
(Q1) (4 marks)
#include <iostream.h>
void main()
void DoIt(int **y) {
{ int **y;
int base = 10; y = new int*[2];
for (int r=0; r<2; r++) for (int i=0; i<2; i++)
{ y[i] = new int[3];
for (int c=0; c<3; c++)
{ DoIt(y);
y[r][c] = base; Come(y);
base += 10;
} y++;
} Come(y);
}
y[0]++;
void Come(int **y) Come(y);
{
for (int r=0; r<2; r++)
{ }
for (int c=0; c<3; c++)
{
cout<<y[r][c]<<" ";
}
cout<<endl;
}
}
Page 1 of 4
University of Modern Sciences & Arts (MSA) Mid-Term Examination-Fall 2003-2004
Fundmentals of computing II (CS-201) Time Allowed: 2.5 Hours
(Q2) (4 marks)
#include <iostream.h>
void main()
{
int *x;
Allocate(x);
Display(x);
Give(x);
Display(x);
Modify(x);
Display(x);
Allocate(x);
Display(x);
}
Page 2 of 4
University of Modern Sciences & Arts (MSA) Mid-Term Examination-Fall 2003-2004
Fundmentals of computing II (CS-201) Time Allowed: 2.5 Hours
Problem 1: (6 marks)
X
1 6 70 6 3 5 55
2 9 19 21 -6 12 10
5 30 17 30 -4 11 11
Y
17 14 15 20 22 24 10 20 22 24 10
3 5 6 4 12 20 35 6 4 12 20 35
88 18 7 10 16 5 8 18 7 10 16 5 8
5 15 25 11 60 4 3 5 15 25 11 60 4 3
For each row in the (Y), determine the largest sorted interval.
Create a third irregular matrix (Z) that carries the largest sorted intervals from (Y).
Y Z
20 22 24 10 20 22 24
6 4 12 20 35 4 12 20 35
18 7 10 16 5 8 7 10 16
5 15 25 11 60 4 3 5 15 25
Display the irregular matrix (Y) and the irregular matrix (Z).
Problem 2: (6 marks)
Page 3 of 4
University of Modern Sciences & Arts (MSA) Mid-Term Examination-Fall 2003-2004
Fundmentals of computing II (CS-201) Time Allowed: 2.5 Hours
Note:
Assume there is a Robot carries number of balls in each of his arms.
NOTE:
The arms will be balanced if the difference between the total weights in the left arm
and the total weights in the right arm was < 25.
Ask the user to select a location (x, y coordinates), and display the information for all Robots
are in this location.
Ask the user to select 2 Robots, also make him to specify an arm (the left or the right one).
Then your program should swap the balls in the specified arm between the 2 selected Robots.
Page 4 of 4