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
valentina_108 [34]
3 years ago
8

The ability to write functions is one of the more powerful capabilities in C++. Functions allow code to be reused, and provides

a mechanism for introducing the concept of modularity to the programming process. In addition to the concept of functions, C++ allows complex programs to be organized using header files (.h files) that contain the prototypes of functions and implementation files that (.cpp files) that contain the implementation (definition) of the functions.
In this programming assignment you will be asked to implement a number of useful functions using a header file and an implementation file. You will place the prototypes for your function in a .h file, and implement these functions in a .cpp file. You will need to write a driver (a program designed to test programs) to test your functions before you upload them.
[edit]Deliverables:
main.cpp
myFunctions.cpp
myFunctions.h
[edit]Function:
[edit]max
Precondition
two integer values exist
Postcondition
The value of the largest integer is returned.
The original integers are unchanged
If the integers have the same value then the value of either integer is returned.
Return
integer
Description
Function returns the value of the larger of two integers.
Prototype:
int max ( int, int )
Sample Parameter Values
m n max(m,n)
5 10 10
-3 -6 -3
Computers and Technology
1 answer:
Lunna [17]3 years ago
6 0

Answer:

The header file in C++ is as follows

myFunction.h

void max(int a, int b)

{

if(a>b)

{

 std::cout<<a;

}

else

{

 std::cout<<b;

}

<em>}</em>

The Driver Program is as follows:

#include<iostream>

#include<myFunction.h>

<em>using namespace std;  </em>

int main()

{

int m,n;

cin>>m;

cin>>n;

max(m,n);

<em>}</em>

Explanation:

It should be noted that, for this program to work without errors, the header file (myFunction.h) has to be saved in the include directory of the C++ IDE software you are using.

For instance; To answer this question I used DevC++

So, the first thing I did after coding myFunction.h is to save this file in the following directory  ..\Dev-Cpp\MinGW64\x86_64-w64-mingw32\include\

Back to the code

myFunction.h

void max(int a, int b)  {

-> This prototype is intialized with integer variables a and b

if(a>b)  -> If the value of a is greater than b;

{

 std::cout<<a;  -> then the value of variable a will be printed

}

else

-> if otherwise,

{

 std::cout<<b;

-> The value of b will be printed

}

}

Driver File (The .cpp file)

#include<iostream>

#include<myFunction.h>  -> This line includes the uesr defined header

using namespace std;  

int main()

{

int m,n;  -> Two integer variables are declared

      cin>>m;  -> This line accepts first integer input

      cin>>n;  -> This line accepts second integer input

max(m,n);

-> This line calls user defined function to return the largest of the two integer variables

}

You might be interested in
Rafi is developing an application to send urgent information about global health crises over the Internet to hospitals. He is wo
Liono4ka [1.6K]
Have the packets virtual
6 0
3 years ago
Exceptions can be handled in all of these ways except:
KatRina [158]

Answer: A) Modular decomposition

Explanation: Modular decomposition is the composition of a graphs into small modules. These modules are the subset of the whole graphs and thus the part of the graph. These modules are these very design efficient and so they are not capable of handling the exceptions .They have precise representation which has modules which cannot seem to have exception because that will disturb the structure of the graph .

6 0
3 years ago
Which object waits for and responds toan event from a GUI component?
irakobra [83]

Answer:

The answer is action eventlistener

Explanation:

It is an event handler and it is easy to implement.In java we call them even listeners it is function or a sub routine or a procedure that waits for an event to occur and respond to an event from a GUI component.

8 0
3 years ago
Judy forgot where she saved a certain file on her computer. Therefor, she searches for all files with a jpg file extension. Whic
Keith_Richards [23]
What are these files anyways
6 0
2 years ago
Read 2 more answers
Which type of message format is designed to arouse curiosity, not showing the product or delivering quite enough information to
Anarel [89]

The type of message format that is designed to arouse curiosity by not showing the product or delivering quiet enough information to make sense is teaser. This is a way of providing information that is short and in which it does not identify the product or the whole message itself. 

7 0
3 years ago
Other questions:
  • The set of specific, sequential steps that describe exactly what a computer program must do to complete the work is called a(n)
    10·2 answers
  • Which software application should be used to create a sales pitch to a group of people? Database Email Presentation Word process
    9·1 answer
  • The picture that graphically represents the items you use in Windows is called a/an
    11·1 answer
  • Insurance can help you:
    12·1 answer
  • When users talk about font size,
    10·2 answers
  • What is a text based language that can be used to build all kinds of things ????
    9·1 answer
  • 1.printer is an example of......... device.<br><br>​
    11·2 answers
  • Draw
    7·1 answer
  • Why would you browse by entering a URL rather than use a link in a Web page
    15·1 answer
  • What distinguishes Accenture as a holistic provider of Extended Reality (XR) services?.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!