Question

In: Computer Science

Select all the answers that apply to modular design: 1. A module may not refer to...

Select all the answers that apply to modular design:

1.

A module may not refer to other modules.

2.

Modular design is an important part of procedural programming.

3.

Modular design identifies the components of a program that can be developed independently.

4.

Each module consists of a set of logical constructs that are related to one another.

/////////////////////

Place the following parts of a function header into their correct order:

      -       1.       2.       3.       4.       5.      

closing parenthesis


      -       1.       2.       3.       4.       5.      

return type


      -       1.       2.       3.       4.       5.      

type parameters


      -       1.       2.       3.       4.       5.      

opening parenthesis


      -       1.       2.       3.       4.       5.      

identifier

//////////////////////////////

Select all of the following statements that are true about function coupling.

It is preferable that each module complete it's own calculations and does not pass control to another module.

A module that receives a value and returns the tax owing on that value using a sliding scale is highly coupled.

The less information that passes between the module and the other modules the better the design.

A module that receives 2 dates and returns the number of days between the dates is highly coupled.

Coupling describes the degree of interrelatedness of a module with other modules.

//////////////////////////////////////////

A function that does not return anything must declare the return type as void and is not required to have a return statement, however it is considered a best practice to include "return;" as the last line anyway.

True

False

/////////////////////////////////////////

Consider the following code:

#include<stdio.h>

void addTwo(int* param1, int* param2)
{
    *param1 -= 2;
    *param2 += 3;
    return;
}

int main(void)
{
    int arg1 = 5, arg2 = 7;
    addTwo(&arg1, &arg2);
    printf("arg1 = %d and arg2 = %d\n", arg1, arg2);
    return 0;
}

Select all of the following answers which are true:

1.

This call would cause a run time error:

addTwo(arg1, arg2);

2.

addTwo(&arg1, &arg2);
//outputs "arg1 = 3 and arg2 = 10"

3.

addTwo(&arg1, &arg2);
//outputs "arg1 = 10 and arg2 = 3"

4.

The ability to pass pointers to functions allows us to code functions that can change 2 or more variables when the function is executed.

/////////////////////////////////////////////////////////

Consider this C program:

#include<stdio.h>

void addOne(int *in)
{
    *in += 1;
    return;
}

int main(void)
{
    int arg1 = 4;
    addOne(&arg1);
    printf("The value stored in arg1 is %d\n", arg1);
    return 0;
}

Select from the following answers all that are true:

1.

addOne(&arg1);

When this function call executes the address of arg1 is stored inside the pointer named in.

2.

*in += 1;

Adds 1 to the value stored at the address held inside the pointer in.

3.

printf("The value stored in arg1 is %d\n", arg1);
//outputs "The value stored in arg1 is 5"

4.

When the function addOne() finishes execution the statement return; is required to return control to main()

5.

When the function addOne runs, the pointer variable in stores a copy of the value stored in arg1.

//////////////////////////////////////////////////////////

The following tasks could be performed in one cohesive module:

  • receives a date
  • calculates the fuel required to drive from Toronto to Montreal
  • returns the square root of an imaginary number

True

False

///////////////////////////////////////////

Consider the following code:

#include<stdio.h>

int addThese(int arg1, int arg2)
{
    return arg1 + arg2;
}

int main(void)
{
    int sum1 = 2, sum2 = 3, answer = 0;
    answer = addThese(sum1, sum2);
    printf("%d\n", answer);
    return 0;
}

Select all of the following statements which are true.

arg1 and arg2 are parameters

sum1 and sum2 are arguments

sum1 and sum2 are parameters

arg1 and arg2 are arguments

/////////////////////////////////////

We can access the data in a variable through either the variable name or by dereferencing its address.

True

False

////////////////////////////////////////

Consider this code snippet:

int x = 0;
int *p = &x;
*p = 79567;

After this code snippet runs the address of x is set to 79567.

True

False

/////////////////////////////////////

A function that does not receive any data when called has no parameters and must use the term void in the parameter list.

True

False

//////////////////////////////////////////////////////////////////

Order the following statements so they represent the correct order of operation of the following program:

#include<stdio.h>

int main(void)
{
    printf( "Hello world!\n");
    return 0;
}

      -       1.       2.       3.       4.      

the printf function outputs "Hello world!" followed by a new line


      -       1.       2.       3.       4.      

main() returns control to the OS, with value zero(0)


      -       1.       2.       3.       4.      

printf() returns control to main()


      -       1.       2.       3.       4.      

main() transfers control to printf()

///////////////////////////////////////////////////////////////////////////////////

The following tasks could be performed in one cohesive module:

  • receive a floating point value
  • calculate the GST (VAT) owing on the value received
  • total the received value and the tax
  • return the total

True

False

///////////////////////////////////////////////////////

Every variable in a C program has a unique address.

True

False

////////////////////////////////////////////////////////////////

A pointer variable is not strongly typed, which means that the address of a floating point variable may be stored in an int type pointer.

True

False

Solutions

Expert Solution

A) Answers that apply to modular design: 3,4

1)A module may not refer to other modules- Each module executes a specific code and fulfilfills a particular functionality of the program. To do so it takes in input from some module(s) and gives output to be used by them. Hence every module must refer to some of the modules in the program. No module can remain isolated. So this statement does not apply to modular design.

2)Modular design is an important part of procedural programming- A procedure call basically calls a function and a subroutine that is a part of the same monolithic program.This practice is called structured programming. In case of Modular design divides the goal into sub goals and each subgoal is executed through a separate module, with proper interfacing among them. So this statement does not apply to modular design.

3)Modular design identifies the components of a program that can be developed independently- The philosophy behind modular design approach is to solve the problem by didviding it into subproblems, each of which are independently solvable. So this statement correctly applies to modular design.

4)Each module consists of a set of logical constructs that are related to one another- Each module is responsible for executing a specific purpose which is done by means of logical constructs. So this statement correctly applies to modular design.

B) The correct order is-

1)return type

2)identifier

3)opening parenthesis

4)type parameters

5)closing parenthesis

Example: int add( int, int)

add is a function to add two integer values and return the sum which is again of type integer.

C)Statements that are true about function coupling:

1)It is preferable that each module complete it's own calculations and does not pass control to another module. True. This is the basic definition of modular design

2)A module that receives a value and returns the tax owing on that value using a sliding scale is highly coupled. False. This is an example of data coupling which is the best form of coupling. So these modules are loosely coupled,

3)The less information that passes between the module and the other modules the better the design. True. This prevents interdependance of modules on one another.

4)A module that receives 2 dates and returns the number of days between the dates is highly coupled. False. This is an example of data coupling which is the best form of coupling. So these modules are loosely coupled.

5)Coupling describes the degree of interrelatedness of a module with other modules.True. A good design should aim to minimize coupling.

D) A function that does not return anything must declare the return type as void and is not required to have a return statement, however it is considered a best practice to include "return;" as the last line anyway.

This statement is TRUE because it makes the code safe and there is a clear ending of the code

E) Select all of the following answers which are true-

1)This call would cause a run time error:FALSE

2)addTwo(&arg1, &arg2);
//outputs "arg1 = 3 and arg2 = 10": TRUE

3)addTwo(&arg1, &arg2);
//outputs "arg1 = 10 and arg2 = 3": FALSE

4)The ability to pass pointers to functions allows us to code functions that can change 2 or more variables when the function is executed.: TRUE

F)Select from the following answers all that are true:

1) addOne(&arg1);

When this function call executes the address of arg1 is stored inside the pointer named in. TRUE

2)*in += 1;

Adds 1 to the value stored at the address held inside the pointer in.TRUE

3) printf("The value stored in arg1 is %d\n", arg1);
//outputs "The value stored in arg1 is 5" : TRUE

4)When the function addOne() finishes execution the statement return; is required to return control to main(): TRUE

5)When the function addOne runs, the pointer variable in stores a copy of the value stored in arg1. TRUE

G) The following tasks could be performed in one cohesive module:

  • receives a date
  • calculates the fuel required to drive from Toronto to Montreal
  • returns the square root of an imaginary number

This statement is FALSE. The three tasks are independent in nature and must be done in separate modules.

H)Select all of the following statements which are true.

1)arg1 and arg2 are parameters : TRUE

2)sum1 and sum2 are arguments : TRUE

3)sum1 and sum2 are parameters : FALSE

4)arg1 and arg2 are arguments : FALSE

I)We can access the data in a variable through either the variable name or by dereferencing its address:TRUE

J)int x = 0;
int *p = &x;
*p = 79567;

After this code snippet runs the address of x is set to 79567.

The statement is FALSE. Pointer p contains address of x which is already 79567

K)A function that does not receive any data when called has no parameters and must use the term void in the parameter list.: TRUE. This ensures clean coding

L)Correct order is-

1) main() transfers control to printf()

2) the printf function outputs "Hello world!" followed by a new line

3) printf() returns control to main()

4) main() returns control to the OS, with value zero(0)

M) The following tasks could be performed in one cohesive module:

  • receive a floating point value
  • calculate the GST (VAT) owing on the value received
  • total the received value and the tax
  • return the total

The statement is TRUE. The formula for GST can be progrmmed to compute tax in one module.

N) We can access the data in a variable through either the variable name or by dereferencing its address:TRUE

O)Every variable in a C program has a unique address. This statement is TRUE

P)A pointer variable is not strongly typed, which means that the address of a floating point variable may be stored in an int type pointer. This statement is FALSE


Related Solutions

Which of the following is NOT a benefit of budgeting.  (Select all the answers that apply) a)...
Which of the following is NOT a benefit of budgeting.  (Select all the answers that apply) a) Requires all levels of management to plan ahead b) Facilitates coordination of activities within the business c) It motivates personnel throughout organization to meet planned objectives d) Provides definite objectives for evaluating performance e) The budget provided the foundation for preparing financial statements included in the 10K report to the SEC.
1. Select all the answers that apply.  _____________ refers to how errors or uncertainty in one variable...
1. Select all the answers that apply.  _____________ refers to how errors or uncertainty in one variable multiply when that variable becomes part of a function involving other variables that might involve a certain degree of uncertainty or error as well. IAMs include _______ of the parameters to solve this problem. Propagation of Error; probability distributions Uncertainty Explosions; discount rates Uncertainty Explosions; probability distributions Cascading Uncertainties; discount rates 2.The problem with program-specific CBAs is that _________________________. the benefits are perceived in...
1. An inducer may affect gene expression by binding: (Select all that apply) A. Directly to...
1. An inducer may affect gene expression by binding: (Select all that apply) A. Directly to a consensus sequence on DNA B. An activator protein to remove it from the DNA C. A repressor protein to remove it from the DNA D. A corepressor E. An activator protein to help it bind DNA F. A repressor protein to help it bind DNA 2.What is the main difference between structural genes and control sequences in bacteria? Cite examples for both. 3.How...
Use the following information to answer the next 11 questions. SELECT ALL ANSWERS THAT APPLY. On...
Use the following information to answer the next 11 questions. SELECT ALL ANSWERS THAT APPLY. On May I. Sam Company sold $5,000 of inventory to Bob Company. The sale was made on account and Sam granted Bob credit terms of 2/10. n/30. The inventory cost Sam Company $3,000. On May 3, Bob returned $1,000 of the inventory to Sam. (The inventory returned by Bob cost Sam $600.) On May 9, Bob paid Sam in full for the amount due. 1....
1. The marginal rate of substitution is ________________ (Select all that apply)
1. The marginal rate of substitution is ________________ (Select all that apply)a. Equal to the slope of the budget line at an optimal point if the optimal point is not at a corner.b. How much of each good a consumer can afford.c. The amount of one good an individual would be willing to trade for a different good and be just as well off.d. The slope of the indifference curve.e. Equal to the price ratio at an optimal point if...
Design a strategy to cure a viral disease without harming the patient. Select all that apply....
Design a strategy to cure a viral disease without harming the patient. Select all that apply. Find a process required for viral multiplication that is not needed for host cell survival and block that process. Take a broad spectrum antibiotic in combination with an antiviral agent. Use of immunosuppressive drugs to the affected organ. Find a virus-specific molecule or enzyme not found in the host and target that molecule.
Which of the following scenarios contain nonbiased samples? Select all that apply. Select all that apply:...
Which of the following scenarios contain nonbiased samples? Select all that apply. Select all that apply: To estimate the mean height of students at her school, Kelly collects data by selecting a random group of students within her classroom. Elizabeth wants to estimate the mean grade point average of students at her school. She collects data by recording the grade point average of every 25th student on the list of students after a randomly selected first student. Andrew wants to...
List five types of common errors in taping. Select all that apply. Select all that apply....
List five types of common errors in taping. Select all that apply. Select all that apply. Temperature Remeasuring Using hand signals Tape length Marking Plumbing Tape not level Recording the results please do not copy and paste the wrong answer .
Question 3 This question could have multiple correct answers, select all that apply. Which of the...
Question 3 This question could have multiple correct answers, select all that apply. Which of the following statements are true about a typical histogram. It is used in descriptive statistics. It is used to summarize variable distributions. It can be used for numerical, ordinal, and nominal data. Its shape will tell you about what summary statistics should be calculated.
Select all that applies. There may be more than one correct answers. Which of the following...
Select all that applies. There may be more than one correct answers. Which of the following is a correct initialization of a C string? Group of answer choices string s[20] = "C++"; string s = "C++"; char s[20]; char* s = "C++"; char s[20] = {'C', '+', '+', '\0'}; char s[20] = ""; char s[20] = "C++";
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT