1. When a function returns a value, what declares if it is an integer, float, or
ID: 640177 • Letter: 1
Question
1. When a function returns a value, what declares if it is an integer, float, or char?
2. When a function is called by reference, it is determined by declaring that the calling arguments are
what?
3. When creating an overloaded function, what makes it unique since the function names are identical?
4. If recursion is used for programming then the function has to be ?
5. What is the reference operator and what does it return as its operation result.
6. Suppose the following declaration: int* p. P is what data type?
7. In the above question, how much is the value increased by the increment of p? i.e. p++?
8. What type of pointer points to a value that has no type (undetermined length and dereference
properties)
9. What is a type cast in C/C++?
http://www.cplusplus.com/doc/tutorial/typecasting/
10. Why would a pointer to a function be used?
11. What type of construct is functocall in the following example?
int operation (int x, int y, int (*functocall)(int,int))
12. How is a member accessed with a named declaration of a structure or class?
13. How is a member accessed with a pointer of a structure or class?
14. Using a typedef allows the programmer to do what?
typedef existing_type new_type_name ;
15. Enumerations are used to create what?
Explanation / Answer
===============================================================
1. When a function returns a value, what declares if it is an integer, float, or char?
----------
Answer:
----------
If the function return value it must return the respective datatype value.
For integer the return type is int.
For float the return type is float.
For char the return type is char.
---------
Example:
---------
int add(int a,int b);
float add(float a,float b);
===============================================================
2. When a function is called by reference, it is determined by declaring that the calling arguments are what?
----------
Answer:
----------
When function is being called by reference it must pass the address of values to the refered function.
At function declartion part the function prototype is defined by pointer notation.
---------
Example:
---------
----------------------
calling statement
----------------------
swap(&a,&b);
----------------------
function prototype
----------------------
int swap(int *a,int *b)
===============================================================
3. When creating an overloaded function, what makes it unique since the function names are identical?
----------
Answer:
----------
Overloading functions are the one with two are more functions with the same name but with different signature.
Signature include the return type, and number of arguments to be passed.
---------
Example:
---------
Overloaded functions example
int add(int a,int b);
float add(float a,float b);
===============================================================
4. If recursion is used for programming then the function has to be ?
----------
Answer:
----------
Recursion is function called by itself. In the defination of function block it has to be call the same function to perform operation.
---------
Example:
---------
int fact(int n)
{
if(n==1)
return 1;
else
//calling function by itself
return n*fact(n-1);
}
===============================================================
5. What is the reference operator and what does it return as its operation result.
----------
Answer:
----------
& is the refernce operator it will return the address of the particular varible.
---------
Example:
---------
int a=10;
int b=&a;
b holds the address of a.
===============================================================
6. Suppose the following declaration: int* p. P is what data type?
----------
Answer:
----------
P is pointer data type. The value of P is acccessed by using *p notation.
===============================================================
7. In the above question, how much is the value increased by the increment of p? i.e. p++?
----------
Answer:
----------
p++ increse the pointer value by 2 bytes.
===============================================================
8. What type of pointer points to a value that has no type (undetermined length and dereference properties)
----------
Answer:
----------
void pointers are pointers that point to a value that has no type
===============================================================
9. What is a type cast in C/C++? http://www.cplusplus.com/doc/tutorial/typecasting/
----------
Answer:
----------
Type cast is converting smaller datatype values to larger data type values and vice versa.Typecasting is making a variable of one type, such as an int, act like another type.
---------
Example:
---------
converting int to float.
===============================================================
10. Why would a pointer to a function be used?
----------
Answer:
----------
Inorder to pass the reference of values which are being passed by calling function where there are more than one varaible value to be changed.
Example swapping of numbers.
===============================================================
11. What type of construct is functocall in the following example? int operation (int x, int y, int (*functocall)(int,int))
----------
Answer:
----------
It is stating pointer to function notation.
===============================================================
12. How is a member accessed with a named declaration of a structure or class?
----------
Answer:
----------
Using . operator structure varibles are accessed.
----------
Example:
----------
struct Employee
{
int EID;
string name;
}emp;
emp.EID;
emp.name; gives values
===============================================================
13. How is a member accessed with a pointer of a structure or class?
----------
Answer:
----------
Uisng the -> opeator.
----------
Example:
----------
struct Employee
{
int EID;
string name;
}*emp;
emp->EID;
emp->name; gives values
===============================================================
14. Using a typedef allows the programmer to do what? typedef existing_type new_type_name ;
----------
Answer:
----------
typedef, which you can use to give a type a new name. Following is an example to define a term BYTE for one-byte numbers:
----------
Example:
----------
typedef unsigned char BYTE;
BYTE b1, b2;
===============================================================
15. Enumerations are used to create what?
----------
Answer:
----------
An enumeration is a distinct type whose value is restricted to one of several explicitly named constants ("enumerators").
The values of the constants are values of an integral type known as the underlying type of the enumeration.
===============================================================
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.