Sample Exam
Sample Exam
Sample Exam
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
CIS 1.5 2 nd <strong>Exam</strong><br />
Name:<br />
10 points total:<br />
1 A.<br />
Write prototypes for the following. Do not write the functions.<br />
i) A function called half which will get one double and returns a double.<br />
ii) A function called combine which gets a reference parameter to a string, and a<br />
string value. It returns nothing.<br />
1 B.<br />
What are the following values of x:<br />
i)<br />
int i = 8;<br />
int x = i+4/2;<br />
x = ____________<br />
ii)<br />
int i = 5;<br />
int x = 500/ (i*2);<br />
x = ____________<br />
Page 1 of 8
CIS 1.5 2 nd <strong>Exam</strong><br />
Name:<br />
12 Points<br />
2.<br />
What would be the output by the following section of C++ code?<br />
int main() {<br />
int c[4];<br />
}<br />
// Check carefully.<br />
c[1]=20;<br />
c[2]=40;<br />
c[0]=50;<br />
c[3]=70;<br />
for(int i=0;i
CIS 1.5 2 nd <strong>Exam</strong><br />
Name:<br />
12 Points<br />
3. Fix the following pieces of code:<br />
A. I want to have the program display all the elements in the array that have a value<br />
that is not zero. However something is wrong.<br />
int a[]={7,5,3};<br />
for(int i=0;i
CIS 1.5 2 nd <strong>Exam</strong><br />
Name:<br />
12 points<br />
4.<br />
What would be the output by the following section of C++ code?<br />
int main() {<br />
}<br />
string word="Gumball";<br />
string sentence="Do well";<br />
string temp;<br />
int position;<br />
sentence.erase(2,3);<br />
cout
CIS 1.5 2 nd <strong>Exam</strong><br />
Name:<br />
12 points<br />
5.<br />
What would be the output by the following section of C++ code?<br />
Pay close attention to the values. Please make note as to what the variable's are as they<br />
change.<br />
int mixit(int[],int &);<br />
int main() {<br />
}<br />
int i=2, j[]={5,15,20};<br />
int k=1;<br />
cout
CIS 1.5 2 nd <strong>Exam</strong><br />
Name:<br />
12 points<br />
6.<br />
What would be the output by the following section of C++ code?<br />
void bah(int [], int [], int);<br />
int boo(int, int);<br />
int boo(int item, int test){<br />
if(item==test)<br />
return 0;<br />
else if(item
CIS 1.5 2 nd <strong>Exam</strong><br />
Name:<br />
12 points<br />
7. What would be the output by the following section of C++ code?<br />
isdigit returns true if the character is a digit, otherwise it returns false.<br />
int main() {<br />
string text="*A1B$122LE";<br />
string alpha="AAAA";<br />
string digit="0000";<br />
int x=0;<br />
int y=0;<br />
for(int i=0;i
CIS 1.5 2 nd <strong>Exam</strong><br />
Name:<br />
18 points<br />
8.<br />
Write a program that has the following function:<br />
A function called add10 that will take an array of integers, and the<br />
size of the array. The function will go through and modify all the<br />
values in the array and add 10 to them.<br />
For example, if the array contains:<br />
15 20 25 30<br />
It will become<br />
25 30 35 40<br />
Create an array to hold 100 integers. Write a main program which will<br />
read in from the keyboard 100 integers. After 100 integers have been<br />
read in, call the function the add10.<br />
Page 8 of 8