28 Prog I Examinations
28 Prog I Examinations
(Q1) (4 marks)
void main()
{
int x[] = {10, 20, 30, 40};
DoIt( x , 0);
DoIt( x , 0);
}
Page 1 of 5
University of Modern Sciences & Arts (MSA) End-Term Examination-Fall 2017-2018
Fundmentals of computing (CS-101) Time Allowed: 3 Hours
(Q2) (4 marks)
void main()
{
char x[] = { 'E', 'T', '|', 'R' , 'i', 'A', 't' , 'C' , '\0'};
DoIt(x , 1 , 8);
DoIt(x , 0 , 8);
Page 2 of 5
University of Modern Sciences & Arts (MSA) End-Term Examination-Fall 2017-2018
Fundmentals of computing (CS-101) Time Allowed: 3 Hours
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
X 4 120 70 12 25 43 10 1 90 70 30 55 91 20 25 14 7 1 2 13 30 42 20
5 0 0
Y 70 2 91 9 91 91 9 91 9 91 91 9 91 9 91 91 9 91 9 91 9 25 30
0 1 1 1 1 1 1 1 1
in (Y) : calculate how many odd values in the 2nd half of the array (A)
In (X) : calculate how many odd values in the 1st half of the array (B)
in (Y) :Add (A) to all cells.
in (X) :Subtract (B) from all cells.
Read an array of 600 values. ( Q ).
Using the mentioned protocol: Generate another array (Z) with size 600 from array (Q).
In (X) : read new values from the user.
Using the mentioned protocol: Generate another array (Y) from array (X).
In (Y) : read new values from the user.
Using the mentioned protocol: Generate another array (X) from array (Y).
in (Y) : calculate how many odd values in the 2nd half of the array (A)
In (X) : calculate how many odd values in the 1st half of the array (B)
in (Y) :Add (A) to all cells.
in (X) :Subtract (B) from all cells.
Read an array of 600 values. ( W ).
Using the mentioned protocol: Generate another array (Z) from array (W).
in (Z) : calculate how many odd values in the 2nd half of the array (A)
In (W) : calculate how many odd values in the 1st half of the array (B)
in (Z) :Add (A) to all cells.
in (W) :Subtract (B) from all cells.
In (X) : read new values from the user.
Using the mentioned protocol: Generate another array (Y) from array (X).
in (Z) : calculate how many odd values in the 2nd half of the array (A)
Page 3 of 5
University of Modern Sciences & Arts (MSA) End-Term Examination-Fall 2017-2018
Fundmentals of computing (CS-101) Time Allowed: 3 Hours
In (W) : calculate how many odd values in the 1st half of the array (B)
in (Z) :Add (A) to all cells.
SECTION (III): FUNCTION DESIGN (Total: 16 marks)
Function 1: (8 marks)
Design a function according to the following aspects:
Input: à means given parameter(s), which already entered before passing it to the function
A string (X).
Integer value that represents the nth word. (N).
Example:
Input:
N=3
X w e w a y H E A L T H a l y w e a t h e r y e s \0 …
Output:
X’ H L T H w e w a y H E A L T H a l y w e a t h e r y e s \0 …
Function 2: (8 marks)
Design a function according to the following aspects:
Input: à means given parameter(s), which already entered before passing it to the function
An array of integers (X).
Number of values in the array (N).
Example:
Input:
N = 22
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 17 18 19 2 21
X 6 0
3 11 20 10 18 8 10 21 71 4 30 21 29 19 50 1 9 14 29 0 5 13
Page 4 of 5
University of Modern Sciences & Arts (MSA) End-Term Examination-Fall 2017-2018
Fundmentals of computing (CS-101) Time Allowed: 3 Hours
Output:
ß Diff :8 [11 – 3 ]
ßDiff appeared : 5 times
Page 5 of 5