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
When an interrogator speaks highly about how a crime was committed, hoping to get the suspect to brag about his or her involveme
Alexeev081 [22]

I’d go with b. egotistical, i’m not entirely sure though. It seems like he is trying to appeal to the suspects EGO

8 0
3 years ago
Read 2 more answers
A tower or mini tower pc is a type of all- in -one unit true or false
Svetlanka [38]

Answer:

thx

Explanation:

5 0
3 years ago
Read 2 more answers
Hulu suggestions? I just got it and I wanna know what's good :)
o-na [289]
Anime show: naruto

Drama show: sweet Mongolian

Adventure show: outer banks
6 0
3 years ago
Read 2 more answers
Choose the appropriate computing generation.
tia_tia [17]

Answer:

5th generation : artificial intelligence

3rd generation: integrated circuits

4th generation : microprocessors

5th generation: parallel processing

<em>hope this helps!</em>

5 0
3 years ago
Read 2 more answers
The following method public String removeFromString(String old, String frag) removes all occurences of the string frag from the
Mashutka [201]

private static String removeFromString(String old, String frag)

{

int i = old.indexOf(frag);

while (i> -1) {

String rest = old.substring(i + frag.length());

System.out.println("rest = " + rest);

old = old.substring(0, i);

System.out.println("rest = " + old);

old = old + rest;

System.out.println("rest = " + old);

i = old.indexOf(frag);

System.out.println("i = "+ i);

}

return old;

}

Here the index of first occurrence is obtained outside the “while loop” and if this loop runs until index value is >-1. It extracts the rest of the characters other than “frag” from the index and all the characters for which the given set of characters are removed.

4 0
3 years ago
Other questions:
  • A bit shift is a procedure whereby the bits in a bit string are moved to the left or to the right. For example, we can shift the
    12·1 answer
  • The support group at Universal Containers wants agents to capture different information for product support and inquiry cases. I
    14·1 answer
  • Which of the following things must you do if you are parked on a rural highway?
    8·1 answer
  • The objective of an Enterprise Resource Planning (ERP) system is to create a customized software program that integrates the inf
    14·1 answer
  • The 2 main types of copyright relevant to the recording industry?
    5·2 answers
  • Which of these is not the correct method for moving text in a document in Word 2016?
    14·2 answers
  • A _____ are devices that permit a user to connect to a digital t-carrier service.
    6·1 answer
  • In your own words, describe how a network administrator can use the OSI model to isolate a network problem.
    13·1 answer
  • Which line of code will find the first occurrence of a three in an array?
    5·2 answers
  • I’ll mark brainlest
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!