Worksheetsarray pointer
Total questions: 29
Worksheet time: 15mins
What does the following declaration mean?
int (*ptr)[10];
ptr is array of pointers to 10 integers
ptr is a pointer to an array of 10 integers
ptr is an array of 10 integers
ptr is an pointer to array
An entire array is always passed by ___ to a called function.
A) Call by value
B) Call by reference
C) Address relocation
D) Address restructure
2, 3, 4, 5
1, 2, 3, 4
0, 1, 2, 3
3, 2, 1 0
2,1,15
1,2,5
3,2,15
2,3,20
The __________, also known as the address operator, returns the memory address of a variable.
asterisk (* )
ampersand ( & )
percent sign ( % )
exclamation point ( ! )
A function may return a pointer but the programmer must ensure that the pointer
still points to a valid object after the function ends
has not been assigned an address
was received as a parameter by the function
has not previously been returned by another function
What does the following statement do?
double *num2;
Declares a double variable named num2
Declares and initializes a pointer variable named num2
Initializes a pointer variable named num2
Declares a pointer variable named num2
Assuming ptr is a pointer variable, what will the following statement output?
cout << *ptr;
the value stored in the variable whose address is contained in ptr
the string "*ptr"
the address of the variable whose address is stored in ptr
the address of the variable stored in ptr
Which of the following statements displays the address of the variable numb?
cout << numb;
cout << *numb;
cin >> &numb;
cout << &numb;
A pointer variable is designed to store
any legal C++ value
only floating-point values
an integer
a memory address
■An array is a group of memory locations that have ______________________________.
the same name and different type
the same name
the same name and the same type.
the different name and type
A function can have _____ inside the parenthesis
loops
Arguments/Parameters
Braces
Types
A function that has no return type starts with:
int
void
Arguments
Braces
A function that returns a whole number starts with the word
int
void
string
{ }
Fill in the blank to have this function work properly
_____ function ( ) {
int a = 4;
int b = 5;
cout<<a*b;
}
string
int
void
variable
Fill in the blank to have this function work properly
_____ function ( ) {
string greeting = "Welcome to my game";
return greeting;
}
string
void
int
variable
A function that is not void needs to have a _____ _______
variable calculation
printing statement
Return statement
cout statement
Fill in the blank to have this function work properly
double function ( ) {
int a;
cin >> a;
cout<<"You chose " << a <<endl;
return ____ ;
}
"a"
a
a * 3.14
cin
Voids
A statement that returns a value
A statement that doesn't return a value
A function that return a value
A function that doesn't return a value
iostream
Displays output from the screen and input from the keyboard
Has all the math equations
Counts the time
Checks if the code has a function
If-else
Optional value for the program to execute
Is a condition followed by a statement or a set of statements
Is a statement followed by a condition or a set of conditions
Function with a value
Do while loops
Runs a statement once
Runs a statement twice
Runs a statement multiple times or not within a boolean condition
Doesn't run at all
Switch Statement
Is a statement with a set of conditions called cases
Is a case
Is a condition with no cases
Is a boolean statement
Which of the following is the default return value of functions in C++?
int
char
float
void
What is an inline function?
A function that is expanded at each call during execution
A function that is called during compile time
A function that is not checked for syntax errors
A function that is not checked for semantic analysis
When we define the default values for a function?
When a function is defined
When a function is declared
When the scope of the function is over
When a function is called
it is the statement that indicates a function will be used.
function declaration
function definition
function call
function name
What will be the output of the following C++ code?
10
0
Syntax error
Segmentation fault
It is a return type that means no value is returned.
void
int
double
char
