1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
muminat
4 years ago
14

Below is the prototype for a function that takes two pointers to integer variables as its parameters. The purpose of the functio

n is to exchange the values stored in the integer variables to which the two pointers point. Consider the proposed implementation code for this function and select all options that would correctly accomplish the intent of the function.
void exchange ( int p, int q );

A) void exchange( int p, int q ) {
p = q;
q = p;}
B) void exchange( int p, int q ) {
p = q;
q = p;}
C) void exchange( int p, int q ) {
int temp = *p;
p = q;
*q = temp;}
D) void exchange( int p, int q ) { int *temp = p; p = q; q = temp;}
E) void exchange( int p, int q ){ int temp = p; p = q; q = *temp;}
Computers and Technology
1 answer:
Anvisha [2.4K]4 years ago
3 0

Answer:

The answer is "Option C".

Explanation:

In the given method prototype a method "exchange" is declared, which accepts two integer parameters, that is "p and q", and this method can't return any value because its return type is void. In the method definition time is defined, that both variables is a pointer type, that's  choices c is correct and others were wrong, that can be described as follows:

  • Option A and Option B both are wrong because it can't interchange the value.
  • Option D and Option E both option uses an integer pointer variable "temp", which is not defined in the question, that's why it is incorrect.  
You might be interested in
Write a function DrivingCost() with input parameters drivenMiles, milesPerGallon, and dollarsPerGallon, that returns the dollar
stira [4]

Answer:

// program in C++.

#include <bits/stdc++.h>

using namespace std;

// function to calculate cost

double DrivingCost(double drivenMiles, double milesPerGallon, double dollarsPerGallon){

  double cost;

  //Expression to compute cost

  cost = drivenMiles / milesPerGallon * dollarsPerGallon;

  return cost;

}

// main function

int main()

{

   double drivenMiles, milesPerGallon, dollarsPerGallon;

  //initialise the variables

  drivenMiles = 50;

  milesPerGallon = 20.0;

  dollarsPerGallon = 3.1599;

  //Call function

  double cost = DrivingCost(drivenMiles,milesPerGallon,dollarsPerGallon);

  //Display result

  cout<<"Driven miles : "<<drivenMiles<<endl;

  cout<<"Miles per Gallon : "<<milesPerGallon<<endl;

  cout<<"Dollars per Gallon : "<<dollarsPerGallon<<endl;

  cout << fixed << setprecision(2);

  cout<<"The total driving cost : "<<cost ;

  return 0;

}

Explanation:

Declare and initialize drivenMiles with 50, milesPerGallon with 20.0 and dollarsPerGallon with 3.1599.Call the function DrivingCost() with these parameters,This will calculate the cost and return the value.Print the result after getting the cost.Similarly we can calculate cost for drivenMiles equals to 10 and 400 miles also.

Output:

Driven miles : 50

Miles per Gallon : 20

Dollars per Gallon : 3.1599

The total driving cost : 7.90

5 0
3 years ago
Is the intersection of a column and a row
Alex17521 [72]

A Cell hope you enjoy your answer

3 0
2 years ago
Kris, an IT manager at Park Infosystems, is handling four projects simultaneously. Each project has loaned and shared resources
Natalija [7]

Answer:

many-to-many relationship

Explanation:

They are different types of relationship between projects. A many-to-many relationship occurs when a row in a table associates with many related rows in another table. For example the relationship between an employee and a project, An employee can work on many projects and a project can have many employees working on it.

8 0
3 years ago
Read 2 more answers
Which of the following factors will have the greatest impact on your credit score? I. Length of Credit History II. Payment Histo
dedylja [7]

Answer

Your payment history and your amount of debt has the largest impact on your credit score.

Explanation

A credit score is a numerical expression based on a level analysis of a person's credit files, to represent the creditworthiness of an individual. Lenders or those who makes funds available with the expectation that the funds will be repaid, plus any interest uses  credit scores to determine who qualifies for a loan, at what interest rate, and what credit limits.Your payment history is  one piece of information used in calculating your FICO Scores.

8 0
3 years ago
Read 2 more answers
Media messages are communicated through which of the following:
LenaWriter [7]
All of the above is the answer
3 0
4 years ago
Read 2 more answers
Other questions:
  • which of the following are used on cable trays to protect the cable insulation from direct sunlight? a. barrier strips b. solid
    5·1 answer
  • Keion works as a freelancer creating websites and designing logos for clients. He recently had a hard drive failure and lost wor
    7·1 answer
  • What is an activity that can help you enhance the appearance of your computer’s desktop?
    12·2 answers
  • Which internet resource can you use to publicly describe an adventure trip you recently made?
    6·2 answers
  • A database is a collection of ________ data.
    15·1 answer
  • Which of the following statements is used to terminate the program when closing the frame?
    5·1 answer
  • What are the characteristics of good blogs?
    8·1 answer
  • In what type of attack does the attacker have the ciphertext of several messages that were encrypted with the same encryption al
    14·1 answer
  • Im a beginner programmer. what languages should i learn and how do i get better
    13·1 answer
  • Which option best describes top-down design?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!