A. Circle if the statement is true and ?if the statement is false. (20 Points-4
ID: 3903374 • Letter: A
Question
A. Circle if the statement is true and ?if the statement is false. (20 Points-4 Each) TIF When a function is called, flow of control moves to the function's prototype. TF2) It is possible for a function to have some parameters with default arguments and some without. T/F 3) Global variables are initialized to zero by default 4) One reason for using functions is to break programs into manageable units, or TIF modules 5) A static variable that is defined within a function is initialized only once, the first time TIF the function is called B. Answer the following questions. (20 Points, 4 Each) 1) Look at the following function prototype. int myFunction (double); What is the data type of the function's return value? a) int b) double c) void d) Can't tell from the prototype 2) Here is the header for a function named computeValue: void computeValue (int value) Which of the following is a valid call to the function? a) computeValue(10) b) computeValue(10); c) void computeValue(10); d) void computeValue(int x)Explanation / Answer
Question A:
1) False, when function called flow moves to the function defination
2) YTrue,es, we can have the default arguments
3) True, default values for global variables is 0
4) True,function are used to divide the program into modules
5) True, static variables are initialized only first time
Question B:
1 ) int
2)computeValue(10);
3) C ) 7, getValue() returning the parameter value +5 , here parameter is 2 so 2+5=7
4) B, 1 6 3, here we are b as reference so changes made in the defination will reflect at calling side
Question C:
1)
int getFact(int num){
if(num<0)
return -1;
int fact=1;
for(int i=1;i<=num;i++){
fact=fact*i;
}
return fact;
}
2)
char getGrade(double value){
if(value<0 || value>100)
return 'X';
char res;
if(value>=90)
res='A';
else if(res>=80)
res='B';
else if(res>=70)
res='C';
else if(res >=60)
res='D';
else if(res<60)
res='F';
return res;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.