Write a C++ program to add two integers. Make a function add() to add integers and display sum in main() function.

Answers

Answer 1

Answer:

In C++:

#include <iostream>

using namespace std;

int add(int a, int b){

   int c = a + b;

   return c;

}

int main(){

   int a, b;

   cout<<"Enter two numbers: ";

   cin>>a;

   cin>>b;

   cout<<add(a,b);

   return 0;

}

Explanation:

The add() function begins here

int add(int a, int b){

This adds the two integers

   int c = a + b;

This returns the sum of the two integers

   return c;

}

The main begins here

int main(){

This declares two numbers

   int a, b;

This prompts user for two numbers

   cout<<"Enter two numbers: ";

The next two lines gets the two numbers

   cin>>a;

   cin>>b;

This gets the sum of the two numbers from the add() function. The sum is also printed

   cout<<add(a,b);

   return 0;

}


Related Questions

Lin wants to play an online game with her friends. She read the description of the game and knows it contains several features with addictive design, including rewards for completing levels and long game times with penalties for quitting early. She likes the game but doesn’t want to get sucked in and skip her homework (which has happened before)! Name two guidelines Lin should set for herself before playing the game.

Answers

Answer:

Set a time limit for herself. Ask her parents for help monitering her app usage.

if you hard working right now go to this EASY question


#BRAINLY and I will give you brainlist something I forgot what's it called for your hard work

Answers

Ok, where is the question so I can try my best?
Whats the question??? Lol

What are the differences between linear algorithm and iterative algorithm

Answers

Answer:

For example Tower of Hannoi algorithm is made easy by recursion while iterations are widely used, efficient and popular. Recursive vs Iterative Algorithms: Approach: In recursive approach, the function calls itself until the condition is met, whereas, in iterative approach, a function repeats until the condition fails.

Why is it a good practice to use functions in programming? Select the best answer.

A.It is faster to run the code using functions.

B.Functions allow us to reuse common code.

C.All of these are correct.

D.It is easier to debug the code using functions.

Answers

Answer:

C. All of these are correct answer from the options for the question that u have given...

The good practice to use functions in programming is all of these are correct. The correct option is C.

What are functions in programming?

The repetitious codes are removed by breaking a program down into functions, which not only reduces the size of the program but also improves its effectiveness. If there were repetitive codes, we would need to alter the program from several locations rather than just one.

As a result, organizing programs into functions aid in good administration and shortens programs by removing repeated code. A functional programming language is a particular kind of language that allows for the creation and application of pure mathematical functions, along with the use of conditional expressions and recursion to carry out various computations.

Therefore, the correct option is C. All of these are correct.

To learn more about functions in programming, refer to the link:

https://brainly.com/question/24297344

#SPJ6

Use the drop-down menu to complete the steps for using the Goal Seek feature.
1. Go to the
tab.
2. In the
from the drop-down What-If Analysis menu.
3. Specify the cell that contains the formula to solve and enter the desired result.
4. Specify the
that contains the value to adjust.
5. Click OK
group, select

Answers

Answer:

1. Go to the  data tab.

2. In the  forecast ribbon from the drop-down What-If Analysis menu.

3. Specify the cell that contains the formula to solve and enter the desired result.

4. Specify the  changing cell that contains the value to adjust.

5. Click OK

Answer: see below

Explanation:

Two friends can share 100 songs from their Bluetooth enabled mobile devices
a. True
b. False
c. They need internet connection
d. Not sure

Answers

Answer:

A

Explanation:

If they are connected via bluetooth, you can share unlimited amounts of anything.

True or false: Machine learning lets computers
learn how to do things they weren't
specifically programmed to do.

Answers

Answer:

True

Explanation:

What is the Denary representation of this 8 bit number > 01001111 ?

Answers

The Denary representation of this 8 bit number 01001111 is 79.

Decimal number

A binary number is a number expressed in the base-2 numeral system or binary numeral system. Binary numbers are either 0 or 1.

The decimal numeral system is the standard system for denoting numbers. Decimals are a set of numbers lying between integers on a number line.

Converting the number 01001111 to decimal:

01001111 = (0 * 2)⁷ + (1 * 2)⁶ + (0 * 2)⁵ +  (0 * 2)⁴ +  (1 * 2)³ +  (1 * 2)² + (1 * 2)¹ + (1 * 2)⁰ = 79

The Denary representation of this 8 bit number 01001111 is 79.

Find out more on Decimal number at: https://brainly.com/question/1827193

Where are methods listed in a UML class diagram showing three parts?
in the top third of the diagram
in the middle third of the diagram
in the bottom third of the diagram
anywhere in the diagram a lowercase m is shown

Answers

Answer:

the bottom third

Explanation:

Check out the exampe below.

swim() would be an example of a method.

You learned that you can use the tags to insert a link to another webpage. One problem that webpage developers face is that, after a time, links may no longer work. Can you think of ways that you can avoid broken links?

Answers

Answer:Image Control

We can use the height and width properties to control the size of our image. Let’s say we only want the recipe image to take up approximately one-third of the page. Do you remember from math class what percentage one-third is? Type in the following CSS rule, and watch your picture change size before your very eyes!

img {

   height:33%;

   width:33%;

}

That wasn’t too difficult, right? Let’s make the image stand out a bit more by adding a border. Inside the img rule, add the following declarations:

border-style:dashed;

border-width: 5px;

Your picture should now have a dashed border around it that is five pixels in width. Play around with the different border styles that are available. You should see a drop-down box of choices, including dotted, dashed, double, groove, inset, and outset. You can also adjust the width of your border. Using your informative guessing skills, can you predict what property you might use to change the color of the border? Try it and see if you’re right!

Explanation:

 this is a direct quote from my lesson

Other Questions
Which of the following processes does the body NOT use protein to perform?A.repairing musclesB.producing hormonesC.making hemoglobinD.creating amino acids Qu razones hicieron que se buscar una nueva ruta martima hacia el lejano oriente qu descubrimientos cientficos y tcnicos lo facilitaron when we have to make economic choices in our lives? In ARST, the measure of T=90, ST = 7.7 feet, and RS = 9.7 feet. Find the measureof R to the nearest degree.9.77.7XTRAnswer:Submit Answer Q1} What is the greatest common factor of 24 and 40? A. 2 B. 6 C. 8 D. 24Q2} Which list shows all the factors of 48? A. 1, 2, 4, 6, 8, 12, 24, 48 B. 1, 2, 3, 4, 6, 8, 9, 12, 16, 24, 48 C. 1, 2, 3, 4, 6, 8, 12, 16, 24, 48 D. 1, 2, 3, 4, 6, 8, 9, 12, 16, 24, 48Q3} What is the greatest common factor of 60, 84 and 72? A. 4 B. 12 C. 24 D. 84Q4} Which list shows all the factors of 36? A. 1, 2, 3, 4, 6, 12, 18, 36 B. 1, 2, 3, 4, 6, 9, 12, 18, 36 C. 1, 2, 3, 4, 5, 9, 12, 18, 36 D. 36, 72, 108, 144, 180Q5} Which list shows all the factors of 54? A. 1, 2, 3, 6, 9, 12, 18, 27, 54 B. 1, 2, 3, 6, 9, 18, 27, 54 C. 1, 2, 3, 6, 9, 18, 54 D. 1, 2, 3, 4, 6, 9, 12, 18, 27, 54plz hury i am on a test 100 points and Brainlyeist Select the correct answer.Which term best completes the sentence?Los criollos eran los descendientes deO A. indgenasB.espaolesOc.mestizosOD. pardos What is the volume of the pyramid? Solve for q.7(q + 7) = 5q + 59 Triangle XYZ with vertices X (1,-2) Y (3,-5) and Z (4,1) translated 5 units left and 3 units up How many moles are there in 17.6g NaOH? Why do not all rock types contain fossils?Excessive heat and pressure can destroy fossils.Fossils can only be created in certain places around the world.Fossils cannot be created near volcanoes.Fossils are too large to be found in igneous and metamorphic rocks. URGENT NEED ANSWERS _ the executive branch is made up of what that supports the implementation of Georgia's law 7. Look at this figureThere are different shapes in the figure (Do not count thetrapezoid itself)b29:24 AM2/9/2029 Juan bought a laptop for $650 and a power adapter for $59. If the sales tax rate is 6%,what was the total tax that Juan paid? Hey I'm Chloe, Can You Help Me Thank you :)y varies proportionally with x. When x = 2, y = 18.What is the constant of proportionality for this relationship? Functions:Question 5What is the y-intercept of the line whose equation is shown below?y = - 3.3 +7Select one:3-347 The objective of this task is to use Scapy to estimate the distance, in terms of number of routers, between your VM and a selected destination. This is basically what is implemented by the traceroute tool. In this task, we will write our own tool. The idea is quite straightforward: just send an packet (any type) to the destination, with its Time-To-Live (TTL) field set to 1 first. This packet will be dropped by the first router, which will send us an ICMP error message, telling us that the time-to-live has exceeded. That is how we get the IP address of the first router. We then increase our TTL field to 2, send out another packet, and get the IP address of the second router. We will repeat this procedure until our packet finally reach the destination. It should be noted that this experiment only gets an estimated result, because in theory, not all these packets take the same route (but in practice, they may within a short period of time). The code in the following shows one round in the procedure. a = IP() a.dst = 1.2.3.4 a.ttl = 3 b = ICMP() send(a/b) If you are an experienced Python programmer, you can write your tool to perform the entire procedure automatically. If you are new to Python programming, you can do it by manually changing the TTL field in each round, and record the IP address based on your observation from Wireshark. Either way is acceptable, as long as you get the result. Which statement best compares Earths crust to its mantle? A. The crust only contains nonmetals, and the mantle contains metals. B. The mantle is the thinnest layer, and the crust is the thickest. C. The mantle only contains nonmetals, and the crust contains metals. D. The crust is the thinnest layer, and the mantle is the thickest. Use distributive property to write an equivalent expression. Use paper and pencil towork the problems out, and then check your answers once you have submitted thepractice. (Answers will be in the bubbled comments after the problem.)A. 6 Gn+2)B.p(4p +9)C. 5r (r + 4