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
rusak2 [61]
3 years ago
5

Write a function namedadd_complex that adds the correspondingnumbers of its arguments (both complexstructures), then returns the

result (anothercomplex structure)
Computers and Technology
1 answer:
amid [387]3 years ago
3 0

Answer:

#include <iostream>

using namespace std;

struct complex{//structure of comlex number..

double real;

double img;

};

complex add_complex(complex n1,complex n2)//add_complex functrion to add 2 complex numbers..

{

   double a,b;//variables to hold the sum of real and imaginary.

   complex sum;//result sum complex number.

   a=n1.real+n2.real;//adding real parts.

   b=n1.img+n2.img;//adding imaginary parts..

   sum.real=a;//assinging values to sum.

   sum.img=b;

   return sum;//returning complex number sum.

}

int main()

{

 complex c1,c2,sum;

 double a,b;

 cout<<"Enter values of c1"<<endl;

 cin>>a>>b;

 c1.real=a;

 c1.img=b;

 cout<<"Enter values of c2"<<endl;

 cin>>a>>b;

 c2.real=a;

 c2.img=b;

 sum=add_complex(c1,c2);

 cout<<"The sum is : "<<sum.real<<" + i"<<sum.img<<endl;

 return 0;

}

OUTPUT:-

Enter values of c1

8.5 7.2

Enter values of c2

4.5 3.9

The sum is : 13 + i11.1

Explanation:

First I have created a structure for complex number.Then created a function to add two complex numbers according to the question which returns a complex number.

You might be interested in
What are some real-life situations that require a program that is iterative? Include at least three examples in your answer.
Hunter-Best [27]
<h2>Hello :D</h2>

Your answer should be:

Apple has released multiple different versions of each model of its iPod products. The Nano, for example, has evolved from an original slim mP3 player with a very small screen to a tiny square touch-screen version to a longer, thinner touch screen version.

<em>Hope this helped! </em>

<em>Brainliest appreciated :3</em>

7 0
3 years ago
Read 2 more answers
The "offset" between the viewfinder and the lens in compact cameras results in a problem called
boyakko [2]
The answer is Parallax.

5 0
4 years ago
ASAP NEED HELP ASAP NEED HELP ASAP NEED HELP ASAP NEED HELP ASAP NEED HELP ASAP NEED HELP ASAP NEED HELP ASAP NEED HELP​
anyanavicka [17]

Answer:

<em><u>1</u></em><em><u>3</u></em><em><u>.</u></em><em><u>c</u></em>

<em><u>1</u></em><em><u>4</u></em><em><u>.</u></em><em><u>d</u></em>

<em><u>1</u></em><em><u>5</u></em><em><u>.</u></em><em><u>b</u></em>

<em><u>1</u></em><em><u>6</u></em><em><u>.</u></em><em><u>a</u></em>

<em><u>1</u></em><em><u>7</u></em><em><u>.</u></em><em><u>c</u></em>

Explanation:

<em><u>please</u></em><em><u> </u></em><em><u>brainleist</u></em><em><u> </u></em><em><u> </u></em><em><u>please</u></em><em><u> </u></em><em><u>☻</u></em><em><u>☺️</u></em><em><u>❤</u></em><em><u>♨️</u></em>

8 0
3 years ago
Read 2 more answers
You want to search for contacts in your email program. You enter the person’s first name and last name in the search box. You wa
ryzh [129]

Answer:

NOR

Explanation:

6 0
3 years ago
Read 2 more answers
Show the array that results from the following sequence of key insertions using a hashing system under the given conditions: 5,
sergejj [24]

Answer:

a) Linear probing is one of the hashing technique in which we insert values into the hash table indexes based on hash value.

Hash value of key can be calculated as :

H(key) = key % size ;

Here H(key) is the index where the value of key is stored in hash table.

----------

Given,

Keys to be inserted are : 5 , 205, 406,5205, 8205 ,307

and size of the array : 100.

First key to be inserted is : 5

So, H(5) = 5%100 = 5,

So, key 5 is inserted at 5th index of hash table.

-----

Next key to inserted is : 205

So, H(205) = 205%100 = 5 (here collision happens)

Recompute hash value as follows:

H(key) =(key+i) % size here i= 1,2,3...

So, H(205) =( 205+1)%100 = 206%100 = 6

So, key 205 is inserted in the 6th index of the hash table.

----------

Next Key to be inserted : 406

H(406) = 406%100 = 6(collision occurs)

H(406) =(406+1) %100 = 407%100 = 7

So, the value 406 is inserted in 7the index of the hash table.

-----------------

Next key : 5205

H(5205) = 5205%100 = 5(collision)

So, H(5205) = (5205+1)%100 = 6( again collision)

So, H(5205) = 5205+2)%100 = 7(again collision)

So, H(5205) = (5205+3)%100 = 8 ( no collision)

So, value 5205 is inserted at 8th index of the hash table.

-------------

Similarly 8205 is inserted at 9th index of the hash table because , we have collisions from 5th to 8th indexes.

-------------

Next key value is : 307

H(307) = 307%100 = 7(collision)

So, (307+3)%100 = 310%100 = 10(no collision)  

So, 307 is inserted at 10th index of the hash table.

So, hash table will look like this:

Key       index

5         5

205         6

406         7

5205 8

8205 9

307         10

b) Quadratic probing:

Quadratic probing is also similar to linear probing but the difference is in collision resolution. In linear probing in case of collision we use : H(key) = (key+i)%size but here we use H(key) =( key+i^2)%size.

Applying Quadratic probing on above keys:.

First key to be inserted : 5.

5 will go to index 5 of the hash table.

-------

Next key = 205 .

H(205) = 205%100 = 5(collision)

So. H(key)= (205+1^2)%100 = 6(no collision)

So, 205 is inserted into 6th index of the hash table.

--------

Next key to be inserted 406:

So, 406 %100 = 6 (collision)

(406+1^2)%100 = 7(no collision)

So, 406 is moved to 7th index of the hash table.

----------

Next key is : 5205

So, 5205%100 = 5 (collision)

So, (5205+1^2)%100 = 6 ( again collision)

So, (5205+2^2)%100 = 9 ( no collision)

So, 5205 inserted into 9th index of hash table.

-----------

Next key is 8205:

Here collision happens at 5the , 6the , 9th indexes,

So H(8205) = (8205+4^2)%100 = 8221%100 = 21

So, value 8205 is inserted in 21st index of hash table.

--------

Next value is 307.

Here there is collision at 7the index.

So, H(307) = (307+1^2)%100 = 308%100= 8.

So, 307 is inserted at 8the index of the hash table.

Key           Index

5                  5

205                  6

406                  7

5205                9

8205               21

307                   8

3 0
3 years ago
Other questions:
  • What is the basic difference between x.509 and pgp in terms of key hierarchy and key trust?
    12·1 answer
  • Attacker player X is standing still on a corner kick, as the ball is played, he jumps up with his arms flailing above his should
    8·1 answer
  • To insert a field between existing fields, right-click the column heading for the field that will follow the new field, and then
    11·1 answer
  • A color tv uses red, green, and blue phosphors to produce the colors that we see. in printing, however, we use magenta, yellow,
    10·1 answer
  • Differentiate between Software as a service, platform as a service and infrastructure as a service.
    14·1 answer
  • First identify the formula to compute the sales in units at various levels of operating income using the contribution margin app
    12·1 answer
  • A user complains that her computer is performing slowly. She tells you the problem started about a week ago when new database so
    12·1 answer
  • A friend is interested in keeping track of information about his album collection. He is not concerned about whether or not the
    11·1 answer
  • To cope with the uncertainty about how their pages will be viewed, many web page designers opt to use _________ units, which are
    13·1 answer
  • Animation affects can be applied on both................ and................ on a slide​
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!