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
How do you use loops in code?
Keith_Richards [23]

Answer:

A loop in a computer program is an instruction that repeats until a specified condition is reached. In a loop structure, the loop asks a question. If the answer requires action, it is executed. ... A computer programmer who needs to use the same lines of code many times in a program can use a loop to save time

Explanation:

4 0
3 years ago
Robots are increasingly being used in caring roles. Discuss the ethical and cultural implications of this trend
vekshin1
Using more robots means less human contact which means declining social skills, and heavier dependence on technology. And using more technology is expensive.
4 0
3 years ago
Which type of work is an electrical engineer most likely to do?
yKpoI14uk [10]

Answer:

B

Explanation:

design and analyze electrical devices

7 0
3 years ago
How has technology impacted society and education throughout history? What innovation has had the most profound impact on educat
Ganezh [65]
Technology has impacted society and education throughout history by helping save more lives and distroying​ them. I think the innovation that has had the most profound on education is being able to connect with teachers to better help us understand even we are not in school like what I am doing right now.
8 0
3 years ago
Read 2 more answers
What is a database in access
aliya0001 [1]
Microsoft Access is a database management system (DBMS) from Microsoft that combines the relational Microsoft Jet Database Engine with a graphical user interface and software-development tools. ... It can also import or link directly to data stored in other applications and databases.
6 0
3 years ago
Other questions:
  • The inventory tracking system shows that 12 laptop were on hand before a customer brings two laptops to the register for purchas
    9·1 answer
  • Match the description to the step in troubleshooting.
    10·1 answer
  • Which key you should you press to leave the cell as it orginally was
    14·2 answers
  • . When a function template has two parameterized types, one as the return value, and one as an argument, then _____.
    11·1 answer
  • Whats 9+9+9+9x999-86 divided by 874 times 8764
    15·2 answers
  • Beneficios del reciclaje electrónico
    6·1 answer
  • Services such as water, electricity, and phone communications are called:
    7·1 answer
  • Write a statement to add the key Tesla with value USA to car_makers. Modify the car maker of Fiat to Italy. Sample output for th
    13·1 answer
  • The hostel in which you plan to spend the night tonight offers very interesting rates, as long as you do not arrive too late. Ho
    5·1 answer
  • NO LINKS Please
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!