29 Prog I Examinations
29 Prog I Examinations
(Q1) (4 marks)
void main()
{
int x[] = {10, 20, 30, 40};
int y[] = {2, 1, 0, 3};
int z[] = {0, 2, 3, 1};
Page 1 of 5
University of Modern Sciences & Arts (MSA) End-Term Examination-Spring 2018
Fundmentals of computing (CS-101) Time Allowed: 3 Hours
(Q2) (4 marks)
void main()
{
char y[8];
int N = 8;
cout<<x<<endl;
DoThat(x[4] , y, N);
int a = 3;
N--;
for (int i=0; i<7; i++)
{
DoThat(x[a] , y, N);
N--;
a+=2;
}
cout<<y<<endl;
}
Page 2 of 5
University of Modern Sciences & Arts (MSA) End-Term Examination-Spring 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
X 4 35 47 12 20 4 10 15 9 70 30 12 33 2 250 14 1 1 90 1 45
3 1 0 7 3
Y 4 1 10 70 33 14 90 35 4 20 43 1 91 30 1 20 250 17 1 1 45
2 7 5 2 3
in (Y) : calculate the average of the 1st part of the array (a1)
In (Y) : calculate the average of the 2nd part of the array (a2)
in (Y) : calculate how many cells < (a1).
in (Y) : calculate how many cells < (a2).
Read an array of 300 values. ( Q ).
Copy One but Two: from (Q) to à (Y) [as explained before].
in (Y) : calculate the average of the 1st part of the array (a1)
In (Y) : calculate the average of the 2nd part of the array (a2)
in (Y) : calculate how many cells < (a1).
in (Y) : calculate how many cells < (a2).
In (X) : read new values from the user.
Copy One but Two: from (X) to à (Y) [as explained before].
in (Y) : calculate the average of the 1st part of the array (a1)
In (Y) : calculate the average of the 2nd part of the array (a2)
in (Y) : calculate how many cells < (a1).
in (Y) : calculate how many cells < (a2).
In (Q) : read new values from the user.
Copy One but Two: from (Q) to à (Y) [as explained before].
in (Y) : calculate the average of the 1st part of the array (a1)
In (Y) : calculate the average of the 2nd part of the array (a2)
in (Y) : calculate how many cells < (a1).
in (Y) : calculate how many cells < (a2).
Page 3 of 5
University of Modern Sciences & Arts (MSA) End-Term Examination-Spring 2018
Fundmentals of computing (CS-101) Time Allowed: 3 Hours
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=4
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:
Y a l y r e h t a e w \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).
Input: N = 20
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
X 30 12 20 17 18 21 10 8 71 24 90 80 60 50 70 30 9 14 29 10
Output:
Page 4 of 5
University of Modern Sciences & Arts (MSA) End-Term Examination-Spring 2018
Fundmentals of computing (CS-101) Time Allowed: 3 Hours
ß 12 , 8 , 50 , 9
Page 5 of 5