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
Find the domain and range of Y=x^3-9/x-3​
dmitriy555 [2]
847nduak388jejdidmenrf838484858686
6 0
3 years ago
How should you behave in an online academic environment?
Kisachek [45]

Answer:

as u want lol

I think it's funny

8 0
3 years ago
Read 2 more answers
How would you like your social media profiles/personas to be treated in the event of your death? why?
White raven [17]
Depends on the person really. personally i would like it all to be kept for memories but never used anymore
7 0
3 years ago
Read 2 more answers
Describe the difference between information poor and information rich society?​
Nadya [2.5K]

Answer:

The “Information poor” are consumers who use traditional mass media information such as television, DVDs, radios and magazines. ... On the opposite “information rich” stands for a new elite within the information society.

7 0
3 years ago
Read 2 more answers
What makes your microphone sound better?
aliya0001 [1]

Answer:

Try playing with its settings. (if it has any), Or maybe put a pop filter on the microphone to improve voice clarity. (can be an old sock), Please read some forum on the topic or better yet find out the manufacture(brand) of your microphone, and then read their recommendations.

Explanation:

8 0
3 years ago
Other questions:
  • Where is the typical location of a touchpad inside of a laptop?
    14·1 answer
  • Monica needs a printer to use at home. She wants fine-quality prints at an affordable cost. Which printer will help her achieve
    9·1 answer
  • A device that modulates digital data onto an analog signal and then demodulates the analog signal back to digital data is a ____
    8·1 answer
  • How do you plan to keep your personal and professional connections and activity seperate on various social media platforms?
    15·1 answer
  • In your own words, describe the advantages and disadvantages of the auto-negotiation protocol used in Ethernet communications.
    6·1 answer
  • 13) What are the benefits and detriments of each of the following? Consider both the systems and the programmers’ levels. a. Sym
    14·1 answer
  • In which of the following situations will a macro make your work more efficient?
    7·1 answer
  • As you are talking to your colleague over the phone, the sound of an airplane flying low drowns out part of your conversation. I
    11·1 answer
  • Fill in the blank: _________ is Google’s machine-learning artificial intelligence system that interprets people’s searches to fi
    9·1 answer
  • Fort Nite is the best u can’t say it’s not
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!