University of Maryland Eastern Shore | The Eastern Shore's ...
CSDP222 Fall, 2011 Test 1 09-29-2011
This test is closed book.
1) Circle and correct the errors in the following program (program continues on next page):
(there are 6 errors)
#include
#include
#include
using namespace std;
const int SIZE = 20;
int my_strstr (char &str_to_check [], char &str_to_find [])
{
int i = 0;
while (str_to_check[i] != '\0')
{
int j = i;
int k = 0;
while (str_to_check[j] != '\0' &&
str_to_find[k] != '\0' &&
str_to_check[j] == str_to_find[j])
{
j++;
k++;
}
if (str_to_check[i] == '\0')
return i;
i++;
}
return -1;
}
void my_strcat (char str_to_concatenate_to [], char str_to_concatenate [])
{
int length_to_str_to_concatenate_to
= stringlen(str_to_concatenate_to);
int b = 0;
}
void main ()
{
char chr_arr [SIZE] = {'A','B','c','a','t','D'};
int index_where_found1 = my_strstr (chr_arr, "cat");
int index_where_found2 = my_strstr (chr_arr, "caz");
my_strcat(chr_arr, "cat");
system("pause");
}
2. A function __________ contains the statements that make up the function.
|a. |definition |
|b. |prototype |
|c. |call |
|d. |expression |
|e. |parameter list |
3. A function is executed when it is
|a. |defined |
|b. |prototyped |
|c. |declared |
|d. |called |
|e. |None of these |
4. The value in this type of local variable persists between function calls.
|a. |global |
|b. |internal |
|c. |static |
|d. |dynamic |
|e. |None of these |
5. Which of the following statements about global variables is true?
|a. |A global variable is accessible only to the main function. |
|b. |A global variable is declared in the highest-level block in which it is used. |
|c. |A global variable can have the same name as a variable that is declared locally within a function. |
|d. |If a function contains a local variable with the same name as a global variable, the global variable's name takes |
| |precedence within the function. |
|e. |All of these are true |
6. If a function is called more than once in a program, the values stored in the function's local variables do not _________ between function calls.
|a. |persist |
|b. |execute |
|c. |communicate |
|d. |change |
|e. |None of these |
7. What is the output of the following program?
#include
using namespace std;
void doSomething(int&);
int main()
{
int x = 2;
cout ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- programming contest preparation
- javascript texas a m university
- student lab 1 input processing and output
- computer science ii juniata college
- department of mathematics and statistics university of
- cs department home
- reminders for students
- python programming project university of south alabama
- technical publications
- list of experiments mait4us
Related searches
- university of maryland jobs baltimore
- university of maryland nursing jobs
- university of maryland hospital jobs
- university of maryland medical system careers
- university of maryland jobs
- university of maryland college park jobs
- university of maryland baltimore jobs
- university of maryland hospital baltimore
- university of maryland baltimore careers
- university of maryland jobs openings
- university of maryland hospital careers
- university of maryland baltimore county jobs