03 Prog I Examinations
03 Prog I Examinations
(Q1) (4 marks)
#include <iostream.h>
void main()
{
int x[] = {10, 20, 15, 40, 50};
DoIt(x);
DoIt(x);
}
Page 1 of 5
University of Modern Sciences & Arts (MSA) End-Term Examination-Spring 2005
Fundmentals of computing for engeeris (CS-101) Time Allowed: 3 Hours
(Q2) (4 marks)
#include <iostream.h>
void main()
{
Page 2 of 5
University of Modern Sciences & Arts (MSA) End-Term Examination-Spring 2005
Fundmentals of computing for engeeris (CS-101) Time Allowed: 3 Hours
SAY that
N1 : 17
N2 : 5
X 3 13 1 17 4 33 5 22 1 5 80 1 14 30 9 1 5 7 9 8
4 7 2
The minimum of all values (4, 33) à (14, 30, 9, 12) in between is: 4.
7 1 18 21 8 37 9 26 5 9 84 21 18 34 13 16 9 11 13 12
7
Subtract this minimum value (8), from all cells in the array.
Display the average of the array.
-1 9 10 1 0 2 1 1 -3 1 7 13 10 26 5 8 1 3 5 4
3 9 8 6
Find the minimum value in all intervals that surrounded by negative values
e.g.
in this state of example the minimum will be: 0.
Add this minimum value (0), to all cells in the array.
Display the average of the array.
Page 3 of 5
University of Modern Sciences & Arts (MSA) End-Term Examination-Spring 2005
Fundmentals of computing for engeeris (CS-101) Time Allowed: 3 Hours
Output:
A third string (Z), that carries all concatenations between the nth word in (X) + each word in
(Y).
Example:
Input:
N=2
X t o r e o n \0 .. .. .. .. .. .. .. .. .. .. ..
Y a d w a r d l Y \0 .. .. .. .. .. .. .. .. ..
Output:
Z r e a d r e w a R d r e l y \0 .. .. ..
Page 4 of 5
University of Modern Sciences & Arts (MSA) End-Term Examination-Spring 2005
Fundmentals of computing for engeeris (CS-101) Time Allowed: 3 Hours
Function 2: (8 marks)
Output:
A third array (Z) that contains a copy of the following values:
- Go forward in array (Y) , and go backward in array (X).
- Copy one cell from Y, and one cell from X, and so on.
- Stop coping when you reach some boundary of any array of both.
- Fill reminder cells in (Z) be zeros.
- The number of non-zero cells in (Z).
Example:
Input:
N=3
X 9 14 79 17 8 15 12 16 3 82
Y 7 61 88 12 45 15 8 22 10 58
Output:
Z 45 7 15 1 8 9 0 0 0 0
9 4
Page 5 of 5