Question

In: Computer Science

Inside “Lab1” folder, create a project named “Lab1Ex3”. Use this project to develop a C++ program...

Inside “Lab1” folder, create a project named “Lab1Ex3”. Use this project to develop a C++ program that performs the following:  Define a function called “Find_Min” that takes an array, and array size and return the minimum value on the array.  Define a function called “Find_Max” that takes an array, and array size and return the maximum value on the array.  Define a function called “Count_Mark” that takes an array, array size, and an integer value (mark) and prints the number of marks that are greater than mark.  Call Find_Min and Find_Max functions.  Call Count_Mark function.

Solutions

Expert Solution

Here our task is to create a c++ program which have 3 functions to find maimum ,minimum and marks greater than given marks

Now let's see what are the the steps to follow,

  • Create a find _max function which recieve array and size .Create a loop inside this function that iterate through each element in the array and check whether each element is greater than the current max if yes change the max variable as current element
  • Same as above create a find _min function which recieve array and size .Create a loop inside this function that iterate through each element in the array and check whether each element is less than the current minimum, if yes change the min variable as current element
  • Create a Count_mark function which also a need a loop which iterate through each element i the array and check whether the current element is greater than the given mark,if yes print that elent
  • In main function create an arry and call all functions whith apropraite parameters

CODE

(Please read all comments for the better understanding of the pogram)

OUTPUT

I am also attching the text version of the code in case you need to copy paste

#include <iostream>

using namespace std;

int Find_Max(int arr[],int length){ //defining Find_max function
int max; // declaring a variable to store current maximum value
max=arr[0]; //initializing max as the first element
for (int i = 0; i < length; ++i) { //loop that iterate through each element in array
  
if (arr[i]>max){ //checking whether current element is greater than current max or not
max= arr[i]; //if yes max variable is changed with value of current element
}
  
}
return max; //returning the max
}

int Find_Min(int arr[],int length){ //defining Find_Min function
int min; // declaring a variable to store current minimum value
min=arr[0]; //initializing min as the first element
for (int i = 0; i < length; ++i) { //loop thta iterate through each element in array
  
if (arr[i]<min){ //checking whether current element is less than current min or not
min= arr[i]; //if yes min variable is changed with value of current element
}
}
  
}
return min; //returning the min
}

int Count_Mark(int arr[],int length,int mark){ //defining Find_Min function
  
cout<<"\nMarks greater than "<<mark<<" are"; //print statement
for (int i = 0; i < length; ++i) { //loop that iterate through each element in array
  
if (arr[i]>mark){ //checking whether current element is greater than mark or not
cout<<"\n"<<arr[i]; //if yes ,print current element
}
  
}
  
}

int main() //main function starts here
{

int arr[10]={77,48,17,64,7,45,94,25,15,36}; //initializing array with values
int max; //declaring min and max
int min;
min=Find_Min(arr,10); //calling Find_Min and store value to min
max=Find_Max(arr,10); //calling Find_Max and store value to max
cout<<"\n max = "<<max; //print statement
cout<<"\n min = "<<min;
Count_Mark(arr,10,35); //calling Count_Mark

return 0;
}


Related Solutions

Inside “Lab1”folder, create a project named “Lab1Ex1”. Use this project to write and run a C++...
Inside “Lab1”folder, create a project named “Lab1Ex1”. Use this project to write and run a C++ program that produces:  Define a constant value called MAX_SIZE with value of 10.  Define an array of integers called Class_Marks with MAX_SIZE which contains students Mark. Define a function called “Fill_Array” that takes an array, and array size as parameters. The function fills the odd index of the array randomly in the range of [50- 100] and fills the even index of...
I. At the beginning, create a folder named "test" and add the folder into the version...
I. At the beginning, create a folder named "test" and add the folder into the version control tool tracking system. Then create one file named "001" under this folder. Commit any change if necessary. II. Next, add another file named "002" in the same folder and commit the change ("adding") in the version control tool. III. Followed by adding that file, create a branch (namely, "branch-A") in the version control tool and make some changes to the contents in file...
In the root of the project create a folder called res. In that folder create a...
In the root of the project create a folder called res. In that folder create a file called DemoFile.txt Create a class with a static main that tests the ability to resolve and print a Path: Create an instance of a FileSystem class. Create an instance of the Path interface for the DemoFile.txt file. Print the constructed Path with System.out.println() method. Create a class that does the following: Using a pre-Java 7 solution, create a class that tests streams in...
C++ Create a program that use the linkedbag 3. Develop a program to maintain a list...
C++ Create a program that use the linkedbag 3. Develop a program to maintain a list of homework assignments. When an assignment is assigned, add it to the list, and when it is completed, remove it. You should keep track of the due date. Your program should provide the following services: • Add a new assignment. • Remove an assignment. • Provide a list of the assignments in the order they were assigned. • Find the assignment(s) with the earliest...
Using NetBeans, create a Java project named FruitBasket. Set the project location to your own folder....
Using NetBeans, create a Java project named FruitBasket. Set the project location to your own folder. 3. Import Scanner and Stacks from the java.util package. 4. Create a Stack object named basket. 5. The output shall: 5.1.Ask the user to input the number of fruits s/he would like to catch. 5.2.Ask the user to choose a fruit to catch by pressing A for apple, O for orange, M for mango, or G for guava. 5.3.Display all the fruits that the...
Create a new Java project named Program 4 Three Dimensional Shapes. In this project, create a...
Create a new Java project named Program 4 Three Dimensional Shapes. In this project, create a package named threeDimensional and put all 3 of the classes discussed below in this package Include a header comment to EACH OF your files, as indicated in your instructions. Here's a link describing the header. Note that headers are not meant to be in Javadoc format. Note that Javadoc is a huge part of your grade for this assignment. Javadoc requires that every class,...
Create a new Java project named Program 4 Three Dimensional Shapes. In this project, create a...
Create a new Java project named Program 4 Three Dimensional Shapes. In this project, create a package named threeDimensional and put all 3 of the classes discussed below in this package Include a header comment to EACH OF your files, as indicated in your instructions. Here's a link describing the header. Note that headers are not meant to be in Javadoc format. Note that Javadoc is a huge part of your grade for this assignment. Javadoc requires that every class,...
11.1 Simple Arithmetic Program Using the instructions from Week 1 Lab, create a new folder named...
11.1 Simple Arithmetic Program Using the instructions from Week 1 Lab, create a new folder named Project01. In this folder create a new class named Project01. This class must be in the default package. Make sure that in the comments at the top of the Java program you put your name and today's date using the format for Java comments given in the Week 1 Lab. For this lab, you will write a Java program to prompt the user to...
At the command prompt: Change to your Downloads folder inside your home folder. Inside your Downloads...
At the command prompt: Change to your Downloads folder inside your home folder. Inside your Downloads folder, create a new folder named "IT1130". Inside the IT1130 folder, enter the following command: date /T > now.txt This last command creates a text file named now.txt containing the current date. Use the more command to display the contents of the now.txt file. Copy and paste the entire output of your more command into the space provided below. There should be one line...
Objectives: 1. Create classes to model objects Instructions: 1. Create a new folder named Lab6 and...
Objectives: 1. Create classes to model objects Instructions: 1. Create a new folder named Lab6 and save all your files for this lab into this new folder. 2. You can use any IDE (such as SciTE, NetBeans or Eclipse) or any online site (such as repl.it or onlinegdb.com) to develop your Java programs 3. All your programs must have good internal documentation. For information on internal documentation, refer to the lab guide. Problems [30 marks] Problem 1: The Account class...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT