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
ivanzaharov [21]
3 years ago
5

8.19 LAB: Max magnitude Write a function max_magnitude() with two integer input parameters that returns the largest magnitude va

lue. Use the function in a program that takes two integer inputs, and outputs the largest magnitude value. Ex: If the inputs are: 5 7 the function returns: 7 Ex: If the inputs are: -8 -2 the function returns: -8 in c language
Computers and Technology
1 answer:
AysviL [449]3 years ago
7 0

Answer:

#include <iostream>

using namespace std;

int max_magnitude(int firstValue, int secValue)//taking two itnerger inputs

{

if (firstValue > secValue)//using if condition

 return firstValue;

else

 return secValue;

}

int main()

{

int firstVal, secVal, finalVal;

cout << "Enter your first value: " << endl;

cin >> firstVal;

cout << "Enter your second value: " << endl;

cin >> secVal;

finalVal = max_magnitude(firstVal, secVal);//calling function

cout << "The greater value is: " << finalVal << endl;

return 0;//terminating program

}

Explanation:

This exercise is for you to understand how to make and call functions. Functions are a way to basically clean the main code. If you read the main code, you can intuitively tell that the finalVal variable is being assigned a max magnitude of some kind. The program would have run absolutely fine if i simply copy pasted the function inside my main. But imagine, if I had to call this function 1000 times, it would've looked quite ugly.

Secondly, there is a certain way how functions work. Function can, and may not take arguments, depending on what it is supposed to do. for example in this case, the function is taking two arguments, because it needs two compare two values from the main function. Now imagine if I made a function to say, exit the program. I would need any arguments. I would simply call the function and it would say 'return 0' and the program will end.

Thirdly, functions may or may not RETURN a value. I our case if you look closely, our function is called 'int' max_magnitude. The int is signalling what type it will return. This means that when the function completes its processing, it will return to where it was called from and give back the value it ended on.

You might be interested in
Identify the modern-day printmaking process, also known as screenprinting, in which the artist squeegees paint through a mesh sc
aliya0001 [1]
Serigraphy is another word for this!
5 0
3 years ago
Which of the following statements is true?
Sonbull [250]

Answer:

C

Explanation:

Predicate methods typically test a condition and do not modify the object on which they're called.

6 0
3 years ago
Write the following arithmetic expression as a valid C arithmetic expression: x = x + number
otez555 [7]

Answer:

x = x + number

x+=number

Explanation:

Given

x = x + number

Required

Write an equivalent expression in C

The given expression uses + and + is represented as + in C

So: The equivalent expression is

x = x + number

However, C supports compound assignment operators

So:

x = x + number

can be rewritten as

x+=number

3 0
3 years ago
Watson Studio is the IBM premier integrated development environment for data science and artificial intelligence practitioners.
fomenos

Answer:

c. Using the Data Refinery tool

Explanation:

Data wrangling and tidying in Data Science is the process whereby data to be analysed is obtained, cleaned and arranged before it is analysed in the environment.

Since Watson Studio happens to be an IBM premier integrated development environment for data science and artificial intelligence practitioners, there is need for them to have data softwares to make data scientists practitioners' works easier.

<em>In this scenario, the best tools to aid in tidying data in the Watson studio would be the use of </em><u><em>Data Refinery Tool.</em></u>

3 0
3 years ago
By default, the windows desktop display
MrRissso [65]
By default, the windows desktop display the following icons/programs

1. Your Recycle Bin
2. My Computer
3. The Internet Explorer
4. The default Windows Background
5. Your windows menu
6. My Documents
7. Your task bar
8. Time (located at bottom right)
6 0
4 years ago
Other questions:
  • Device that converts sound into electrical signals, which are sent to the computer or other recording device
    6·1 answer
  • Helping people keep track on things is the purpose of_____ A database B table C query D form​
    12·1 answer
  • When you catch an Exception object, you can call ____ to display a list of methods in the call stack so you can determine the lo
    6·1 answer
  • The Technology Librarian asks you to find out how many hops it takes to get to the first Wi-Fi kiosk. What Windows command can y
    5·1 answer
  • When an instrument in the dashboard of your car informs you the air pressure in the right rear tire is low, what type of compute
    14·1 answer
  • Miley met up with a bunch of her college friends after several years. She told them that she works for the sound department of a
    5·1 answer
  • Describe a cellular network, its principle<br> components and how it works.
    7·1 answer
  • How would you design an adaptive environment for people who are blind?
    10·1 answer
  • What is a port?
    14·1 answer
  • An entity is said to be _____-dependent if it can exist in the database only when it is associated with another related entity o
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!