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
If you were the IT manager for a large manufacturing company,what issues might you have with the use of opensource software? Wha
Rzqust [24]

Answer: Having the ability to change the source code to fit your needs

Explanation:

7 0
3 years ago
Which statement about broadcasting a slideshow online is true?
9966 [12]

Answer: PowerPoint has a free, built-in service for broadcasting online.

Explanation:

The statement that's true about the broadcast of a slideshow online is that PowerPoint has a free, built-in service for broadcasting online.

Option 1 is wrong as all transitions are not properly displayed to the audience when broadcasting online.

Option 2 is wrong as broadcasting as slideshow online is an option for most PowerPoint users.

Option 3 is wrong because when broadcasting online, third party desktop sharing software isn't necessarily an option and it isn't a must that it must be used.

Therefore, the correct option is 4.

4 0
3 years ago
Read 2 more answers
Computer C’s performance is 4 times as fast as the performance of computer B, which runs a given application in 28 seconds. How
slamgirl [31]

Answer:

112

Explanation:

Since computer C's performance is 4 times faster, naturally I'd multiply 28 by 4.

6 0
3 years ago
(in c++):
Ganezh [65]

The program is an illustration of string manipulations

<h3>What are string manipulations?</h3>

String manipulations include calculating the lengths of strings and also performing several operations on the string

<h3>The actual program</h3>

The complete program in C++ is as follows:

#include <iostream>

using namespace std;

int main(){

   string passwordStr;

   cin>>passwordStr;

   if(passwordStr.length() <= 7){

       cout<<"Valid";

   }

   else{

       cout<<"Invalid";

   }

  return 0;

}

Read more string manipulation at:

brainly.com/question/14284563

6 0
2 years ago
Does anyone know how to execute this assignment on Scratch?
lapo4ka [179]

Execute this assignment from Scratch in the following way

Explanation:

1.For each thread, first Scratch sets the 'active thread' to that thread. Then, it executes each block one by one in the stack for the active thread. It will execute the entire stack all in one go if it can.

2.The Hide block is a Looks block and a Stack block. If the block's sprite is shown, it will hide the sprite — if the sprite is already hidden, nothing happens. This block is one of the simplest and most commonly used Looks blocks.

3.Scratch is used in many different settings: schools, museums, libraries, community centers, and homes.

4.Mitch Resnik, the creator of the super-simple Scratch programming language and head of the Lifelong Kindergarten group at the MIT Media Lab, gave a TEDx talk about the value of coding and computer literacy in early education.

5.

5 0
3 years ago
Other questions:
  • We have to calculate the percentage of marks obtained in three subjects (each out of 100) by student A and in four subjects (eac
    11·1 answer
  • The ability of services to grow or shrink based on need is called __________.
    14·1 answer
  • What is a telecomunications system? 1) A system that enables the transmission of data over public or private networks. 2) A comm
    11·1 answer
  • Which skill type refers to the knowledge and ability to perform a task?
    13·2 answers
  • What is the first step to apply the line and page breaks options to groups of paragraphs in a Word document?
    10·2 answers
  • Select the correct answer from the drop-down menu.
    15·2 answers
  • 80. A .......... is used to read or write data.<br>A. CD B. VDU C. ROM D. RAM​
    6·1 answer
  • What can a user modify on a business card using the Edit Business Card dialog box? Check all that apply.
    6·1 answer
  • _____ is rampant with bugs and shortcomings because most programmers do not know how or do not take the time to incorporate secu
    14·1 answer
  • Think of some local businesses that have websites. Look online and identify two different websites for businesses or services in
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!