19 CS Prog I Examinations
19 CS Prog I Examinations
(Q1) (4 marks)
#include <iostream.h>
void OK ( int q[ ] )
{
for (int i=0; i<6; i++)
cout<<q[i]<<" , ";
cout<<endl;
}
void main()
{
int x[ ] = { 10 , 20 , 30 , 40 , 50 , 60 } ;
int z;
z = x[i+1];
DoIt(x[i], z);
OK(x);
}
Page 1 of 5
University of Modern Sciences & Arts (MSA) End-Term Examination-Spring 2013
Fundmentals of computing (CS-101) Time Allowed: 3 Hours
(Q2) (4 marks)
#include <iostream.h>
void main()
{
char x[ ] = { 'W' , 'E' , 'L' , 'C' , 'O' , 'M' , 'E' , 'a' , 't' , 'm' , 's' , 'a' , '\0' };
Yes(x);
cout<<x<<endl;
}
Page 2 of 5
University of Modern Sciences & Arts (MSA) End-Term Examination-Spring 2013
Fundmentals of computing (CS-101) Time Allowed: 3 Hours
X 6 2 7 11 23 35 4 75 23 74 20 9 30 14 83 33 81 65 16 3 40 12 60 70
5 4
Look to (the first N cells + the last N cells), and reverse them. 3
Before the reverse à [ 6 , 25 , 7 , 11 , 23 , 34 , 40 , 12 , 60 , 70 ]
X 70 60 12 40 3 35 4 75 23 74 2 9 30 14 83 33 8 65 16 23 11 7 2 6
4 0 1 5
1
Calculate the average (avg) of the (in-between cells)
in-between cells
X 70 60 12 40 3 35 4 75 23 74 2 9 30 14 83 33 8 65 16 23 11 7 2 6
4 0 1 1 5
1 Add (avg) to each cell in the last N-cells.
Look to (the first N cells + the last N cells), and reverse them.
Read new array of 100 values (Y).
1 In (Y) : Calculate the minimum of the odd values only (MinOddY). 1.5
In (Y) : Look to (the first N cells + the last N cells), and reverse them. 1
In (Y) : Add (MinOddY) to each cell in the first N-cells.
In (X) : Calculate the minimum of the odd values only (MinOddX).
In (X) : Add (MinOddX) to each cell in the first N-cells.
In (X) : Look to (the first N cells + the last N cells), and reverse them.
Read new (100) values for the array (X).
Read new (100) values for the array (Y).
In (Y) : Calculate the average (avg) of the (in-between cells).
In (Y) : Add (avg) to each cell in the last N-cells.
In (Y) : Add (avg) to each cell in the first N-cells. 4
In (X) : Look to (the first N cells + the last N cells), and reverse them.
In (Y) : Look to (the first N cells + the last N cells), and reverse them.
In (X) : Calculate the minimum of the odd values only (MinOddX).
In (X) : Add (MinOddX) to each cell in the last N-cells.
Read new array of 100 values (Q).
In (Q) : Look to (the first N cells + the last N cells), and reverse them.
In (Q) : Calculate the minimum of the odd values only (MinOddQ).
In (Q) : Add (MinOddQ) to each cell in the last N-cells.
Page 3 of 5
University of Modern Sciences & Arts (MSA) End-Term Examination-Spring 2013
Fundmentals of computing (CS-101) Time Allowed: 3 Hours
Input:
A string (X).
Output:
The number of words in (X).
The same string (X) that modified as the following :
Repeat the word before the last one.
Example:
Input:
W E L C O M E T R A i L H E L L O G O O D \0 ..
X
Output:
The number of words : 4
X’ W E L C O M E T R A i L H E L L O H E L L O G O O D \0
Function 2: (8 marks)
Design a function according to the following aspects:
Input:
An array of integers (X).
Number of values in the array (N).
Output:
- How many cells equal to the maximum value in the array.
- How many cells equal to the minimum value in the array.
Example:
Input: N = 10
X 12 80 7 60 25 4 80 30 4 4
0
Page 4 of 5
University of Modern Sciences & Arts (MSA) End-Term Examination-Spring 2013
Fundmentals of computing (CS-101) Time Allowed: 3 Hours
2
3
Page 5 of 5