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
vladimir1956 [14]
3 years ago
8

Complete the function void update (int *a, int *b), which reads two integers as argument, and sets a with the sum of them, and b

with the absolute difference of them. (7 points)
Computers and Technology
1 answer:
IRINA_888 [86]3 years ago
7 0

Answer:

#include <iostream>

#include <stdio.h>

using namespace std;

// create function called abDifference

void update(int *a,int *b) {

      int r = *a;

#include <iostream>

#include <stdio.h>

using namespace std;

// create function called abDifference

void update(int *a,int *b) {

   int r = *a;

   *a = *a+*b;

   *b = r-*b;

   if(*b < 0)*b *= -1;

}

int main() {

   int num1, num2;

   cout<<"enter two ints"<<endl;

   int *pa = &num1, *pb = &num2;

   scanf("%d %d", &num1, &num2);

   update(pa, pb);

   cout<<num1<<endl;

   cout<<num2<<endl;

   return 0;

}

Explanation:

The function update does two things:

  1. 1. It evaluates the sum of the two arguments passed to it
  2. 2. It evaluates the absolute difference of the two ints passed as an argument

In the main method, the user is prompted to enter two ints. The method update() is called and passed the two ints. It prints the sum as num1 and the abs difference as num2

You might be interested in
You are planning to depart on a flight from area 2 to area 4 in 12 hours. What weather is forecast to occur along your route?
Andre45 [30]
It depends on where you live!
5 0
2 years ago
Which attribute defines the file name for the specific image in an image tag??
serg [7]
Src="/absolute/or/relative/path/to/image.file"
6 0
3 years ago
Consider the security of a mobile device you use
Alekssandra [29.7K]

Answer:

keep it private

Explanation:

7 0
3 years ago
Suppose we wanted to make change for purchases and wanted to use the least number of coins possible. Here is a greedy algorithm:
love history [14]

Answer:

Explanation:

The following code is a Python function that takes in the amount of change. Then it uses division and the modulo operator to calculate the number of coins that make up the changes, using the greatest coin values first.

import math

def amountOfCoins(change):

   print("Change: " + str(change))

   quarters = math.floor(change / 0.25)

   change = change % 0.25

   dimes = math.floor(change / 0.20)

   change = change % 0.20

   pennies = math.floor(change / 0.01)

   print("Quarters: " + str(quarters) + "\nDimes: " + str(dimes) + "\nPennies: " + str(pennies))

5 0
3 years ago
The results of the SPEC CPU2006 bzip2 benchmark running on an AMD Barcelona has an instruction count of 2.389E12, an execution t
xxTIMURxx [149]

Answer:

inside a butt whole

Explanation:

3 0
3 years ago
Other questions:
  • What is the height of the tallest possible red-black tree containing 31 values?
    7·1 answer
  • What file may contain data written to it in case of an unexpected error or program shut-down?
    5·1 answer
  • The principle of time preference requries a larger payment in the future than the present. Which situation best illustrates this
    12·1 answer
  • Once artwork is inserted into a placeholder, it can be moved around on a slide. True False
    9·1 answer
  • Is there a syntax error in the following code? bool hourlyWorker = true; if (hourlyWorker) cout &lt;&lt; "The employee is an hou
    12·1 answer
  • Write a Unix (Linux) find-like command (myFind) in Python3 where the function will return the full paths of all the files contai
    9·1 answer
  • Lamp is an acronym for a complete solution of open source software that goes together to build a general purpose web server. whi
    13·1 answer
  • Which command can be used to find errors on a hard drive​
    6·1 answer
  • 9. Which of the following is the<br>leading use of computer?​
    13·1 answer
  • How do you mark answers brainliest?<br> it looks like they changed it and now idk how to
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!