Question
Mode Function (C++) Basic Steps in Creating your Program Plan your logic before working on the project and review the syntax you will use in
Mode Function (C++)
Basic Steps in Creating your Program
Plan your logic before working on the project and review the syntax you will use in the project. Think about how you want the lines of output to be displayed to the user. You will want to tell the user what the program does and what type of input you expect from the user (Introduction to the User). Select names of the variables you will use in the program.
Create a C++ project in Visual Studio 2012. And have the code window open to write the project code. Display Using Visual Studio to create your program in C++ and follow the instructions on creating the project.
Declare variables to hold information about tank capacity and mpg
Using cout Set up information about this program and what the user will enter and results expected
Ask the user to enter some information requested and save the response to a variable using the cout and cin syntax. Make sure the position for the user to enter information is on the same line as the request for information.
Use line spacing (endl or ) to separate lines of output to make it easy for the user to read the information.
Documentation: All lines of code must be documented.
Use the syntax to designate lines in code as comments (//)
These comments can be at the end of a line of code or in a group definition at the beginning of a section of code. All methods and function need a group heading document.
Run the program using Ctrl+F5. Debug the code, making sure all calculations are correct and the line spacing is suitable for readability.
Your program Assignment
In statistics, the mode of a set of values is the value that occurs most often or with the greatest frequency. Write a function that accepts as arguments the following:
An array of integers
An integer that indicates the number of elements in the array.
The function should determine the mode of the array. That is it should determine which value in the array occurs most often. The mode is the value the function should return. If the array has no mode (none of the values occur more than once), the function should return -1. (Assume the array will always contain nonnegative values.)
Demonstrate your pointer prowess by using pointer notation instead of array notation in the function.
Your program could start out like this
The results of the output could look something like this
All programs this semester should have a looping structure where you ask the user if they want to run the program again.
This program allows the user to input a set of up co 20 integer values, which are stored in an array. it then calculates the mode of the set of values dhich is the ualue that occurs most often or vith the greatest frequency. low many values do you want to store? The number should be between 1 and 20 : The values in numerical order are: 23445566788 The mode is: 4 Do you want to run the program again? Enter Y for YES or any other key for NOStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started