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
weqwewe [10]
3 years ago
5

2. Write these functions definitions:

Computers and Technology
1 answer:
GREYUIT [131]3 years ago
7 0

Answer:

Complete the code with the following code segment:

void add2Numbers(){

   int num1, num2;

   cout<<"Enter any two numbers: ";

   cin>>num1>>num2;

   cout<<num1+num2;

}

void sub2Numbers(){

   int num1, num2;

   cout<<"Enter any two numbers: ";

   cin>>num1>>num2;

   cout<<num1-num2;

}

void mul2Numbers(){

   int num1, num2;

   cout<<"Enter any two numbers: ";

   cin>>num1>>num2;

   cout<<num1*num2;

}

void div2Numbers(){

   int num1, num2;

   cout<<"Enter any two numbers: ";

   cin>>num1>>num2;

if(num2==0){

cout<<"Division by 0 is invalid";

}else{

   cout<<(float)num1/num2;}

}

Explanation:

The function added to this solution are:

  • add2Numbers
  • sub2Numbers
  • mul2Numbers
  • div2Numbers

Each of the functions

  • declares two integers num1 and num2
  • prompt user for inputs
  • gets user inputs from the user

For add2Numbers() function:

This line adds the two integer numbers and prints the result

   cout<<num1+num2;

For sub2Numbers() function:

This line subtracts the two integer numbers and prints the result

   cout<<num1-num2;

For mul2Numbers() function:

This line multiplies the two integer numbers and prints the result

   cout<<num1*num2;

For div2Numbers() function:

This if condtion checks if the denominator is 0

if(num2==0){

If yes, the following is printed

cout<<"Division by 0 is invalid";

If otherwise, the division is calculated and the result is printed

   cout<<(float)num1/num2;

<em>See attachment for complete program</em>

Download cpp
You might be interested in
Please please help me
Sholpan [36]

Answer:

increase your browser security settings

8 0
3 years ago
Helpppppp meeeeeeeeeeeeeeeeee
nikitadnepr [17]
My throat crazyyyyyyy










-xoxoxo
7 0
3 years ago
Network convergence refers to using a single_______________.
CaHeK987 [17]

Answer:

Network, vendor, and bill.

Explanation:

Network convergence is a term used in communication networking that describes the productive synergy among telephone, video, and data transmission using a single network, vendor, and a bill. It enables usage of numerous devices and numerous services with single network, vendor, and bill.

Hence, in this case, it can be concluded that, Network convergence refers to using a single network, single vendor, and single bill.

7 0
4 years ago
Which term describes the variable x in this program?
bazaltina [42]

Answer: a sentinel value

Explanation:

a sentinel value is a value that is used as a condition to end the program. notice that it says "enter -1 to end"

7 0
2 years ago
The Euclidean algorithm - The Euclidean algorithm provides a wonderful way to calculate the greatest common factor of 2 numbers.
Murljashka [212]

The pseudo-code of the algorithm will be:

Start

Set n1 equal to 145 and n2 equal to 87.

Divide n1 by n2 and find the remainder.

Set n1 equal to n2 and n2 equal to the remainder.

Repeat steps 2 and 3 until the remainder is equal to 0.

The greatest common factor is n1.

End

What do you mean by pseudocode?

In computer science, pseudocode is indeed a plain language description of a steps in an algorithm or similar system. Pseudocode frequently employs structural patterns of a conventional programming language, although it is designed for human interpretation rather than machine reading. It generally omits features necessary for computation of the algorithm, including such variable declarations and language-specific code. When possible, the programming language is supplemented by natural language description details or succinct mathematical notation.

To learn more about pseudocode

brainly.com/question/24735155

#SPJ9

4 0
2 years ago
Other questions:
  • Most languages allow a specialized selection structure called the ____ structure when there are several distinct possible values
    8·1 answer
  • Your organization wants to implement a 5-year rotation plan for all of its computing devices. What percentage of the computer fl
    10·2 answers
  • The list below represents the contents of a computer's main memory. I've left every other byte blank. Assume that the letters at
    14·1 answer
  • Kaylen has been working on his computer and notices that the screen seems to be flickering. The monitor is not turning on and of
    13·1 answer
  • Toby has lost valuable data on his computer a number of times due to system crashes caused by viruses. He decides to invest in a
    13·1 answer
  • A circuit contains three resistors connected in parallel. The value of R1 is 2 K , the value or R2 is 6 K , and the value of R3
    5·1 answer
  • What is the correct order of the phases of the software development process?
    14·1 answer
  • Select the correct answer.
    15·1 answer
  • Can Algorithms Be Used Again?
    8·1 answer
  • Today's manufacturing workplace is most likely to include
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!