Exam 3: Function Basics

arrow
  • Select Tags
search iconSearch Question
  • Select Tags

Give an outline for the general form of a programmer defined function.

Free
(Essay)
4.8/5
(38)
Correct Answer:
Verified

return_type funct_name (parameter_list)
{
//function body - compute return_value here
return return_value;
}
Here parameter_list is a comma separated list of entries of the type argument_type argument_name.There could be multiple returns inside a branch.

Extensive use of global variables is a satisfactory replacement for the difficulties of parameter passing with functions.

Free
(True/False)
4.8/5
(33)
Correct Answer:
Verified

False

,A definition of a variable outside any function is called a

Free
(Multiple Choice)
4.9/5
(36)
Correct Answer:
Verified

B

A variable declared within a function block is said to be local to the function.

(True/False)
4.8/5
(35)

Each of the following lines of code purport to round the results of the division of doubles to the nearest integer value (but still of type double).All are correct C++ code but some do not round correctly.Tell which rounds down,up,or to the nearest integer value,or is not reasonable Assume that math.h has been included,and that all variables have appropriate values. double x,y,z; a)z = ceil(x/y); b)z = ceil(x/y-0.5); c)z = floor(x/y-0.5); d)z = floor(x/y+0.5); e)z = floor(x/y);

(Essay)
4.9/5
(45)

Write a function definition for a function called inOrder that takes three arguments of type int.The function returns true if the arguments are in increasing order left to right;otherwise inOrder returns false.For example,inOrder(1,2,3)returns true,whereas inOrder(1,3,2)returns false.

(Essay)
4.8/5
(32)

Consider two blocks,one within another.C++ prohibits an identifier to be declared as a variable in each of these blocks.

(True/False)
4.8/5
(49)

Declare (give a prototype for)a function named average_grade.This function returns a double and has four double arguments,test1,test2,test3,test4.The return value should be the average,or arithmetic mean of the four arguments.Be sure to include a "prototype comment" that tells briefly what the function does.

(Essay)
4.8/5
(33)

What is the error in the following code? Why is this wrong? int f(int x) { int x; // code for function body }

(Essay)
4.9/5
(44)

Given the function declaration (prototype),does the compiler complain or compile if you call this using the following line? If the compiler complains,what is the complaint? //if score >= min_to_pass,returns 'P' for passing, //else returns 'F' for failing. char grade (int score,int min_to_pass); int main() { double fscore; char fgrade; int need_to_pass; //omitted code to get values for variables //fscore and need fgrade = grade(fscore,need); return 0; }

(Essay)
4.8/5
(30)

In C++ Boolean value are represented only with the int values 0 for false and 1 for true.

(True/False)
4.9/5
(39)

Every programmer must know all the details of what that programmer's team mates are doing in their projects to do the work assigned.Why?

(True/False)
4.9/5
(48)

Procedural abstraction involves information hiding in that only the 'contract' between the programmer using the function (the client)and author of a function is known to either.

(True/False)
4.9/5
(47)

Define a function named average_grade.This function returns a double and has four double arguments,test1,test2,test3,test4.The return value should be the average,or arithmetic mean of the four arguments.Be sure to include a comment that tells briefly what the function does.

(Essay)
4.9/5
(41)

Assume this code fragment is embedded in an otherwise correct and complete program.What should be the output from this code segment? { For( int i = 0;i < 10;i++) { ).. } Cout << i << endl; }

(Multiple Choice)
4.8/5
(33)

Code after a return or a call to the exit function is executed will not be executed.

(True/False)
4.9/5
(32)

A sequence of calls to the library function rand()generates mathematically correct random number sequences.

(True/False)
4.9/5
(36)

Write a function definition for a isDigit function that takes one argument of type char and returns a bool value.The function returns true if the argument is a decimal digit;otherwise it returns false.

(Essay)
4.9/5
(38)

A call to a C++ function is

(Multiple Choice)
4.8/5
(29)

Write a function definition called even that takes one argument of type int and returns a bool value.The function returns true if its one argument is an even number;otherwise it returns false.

(Essay)
4.9/5
(30)
Showing 1 - 20 of 30
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)