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
Anna007 [38]
2 years ago
9

Create a function names minElement() that takes an array of numbers as a paaramter and returns the min value of the array. The a

rray may not be modified by the function. The array method .sort() may not be used. The function must loop through the array
Computers and Technology
1 answer:
Vika [28.1K]2 years ago
8 0

Answer:

#include<iostream>

using namespace std;

//create the function

int minElement(int arr[],int n){

   int minimum = arr[0];  //store the first value of array

   //for loop for iterate the each element

   for(int i=0;i<n;i++){

       if(arr[i]<minimum){   //compare

           minimum=arr[i];

       }

   }

   return minimum;

}

int main(){

   int arr[]={4,1,7,9,2,6};

   int array_size = 6;

   int result = minElement(arr,array_size);   //calling

   cout<<"The min value is: "<<result<<endl;

}

Explanation:

First include the library iostream in the c++ programming for input/output.

then, create the function minElement() for find the minimum value in the array.

it required the one loop for iterate the each element in the array and then compare with first element in the array which is store in the variable minimum.

if array element is less than the minimum then, update the value in the minimum variable.

after complete the loop, return the result.

for capture the result create the main function and call the function with parameter array.

and finally display the result.

You might be interested in
Please select the word from the list that best fits the definition
Svetllana [295]

A pie graph shows the percent something takes of a whole. With a pie graph it is always out of 100%, therefor for this question the answer is B. Pie graph

I hope this helped!

7 0
3 years ago
Specific Instructions
Goryan [66]

In the most common use of the term, a class can be seen as a blueprint used to create objects. In other words, object(s) are created from a class in Java.

<h3>Creating a Class</h3><h3>Code:</h3>

import java.util.*;

class Card{

 private String suit;

 private int value;

 public Card(String s,int v){

   suit = s;

   value = v;

 }

 public String getSuit(){

   return suit;

 }

 public int getValue(){

   return value;

 }

 public void display(){

   System.out.println(value+"("+suit+")");

 }

}

class Deck{

 private ArrayList<Card> deck;

 private ArrayList<Card> drawn;

 public Deck(){

   deck = new ArrayList<Card>();

   drawn = new ArrayList<Card>();

   String[] arr = {"Club","Spade","Heart","Diamond"};

   for(String s : arr){

     for(int i=1;i<=13;i++){

       deck.add(new Card(s,i));

     }

   }

 }

 public void draw(){

   drawn.add(deck.get(0));

   deck.remove(0);

 }

 public void draw(int N){

   if(N > deck.size()){

     N = deck.size();

   }

   for(int i=0;i<N;i++){

     draw();

   }

 }

 public void showDrawn(){

   for(Card c : drawn){

     c.display();

   }

 }

 public void shuffle(){

   Collections.shuffle(deck);

 }

 public void restore(){

   restore(drawn.size());

 }

 public void restore(int N){

   if(N > drawn.size()){

     N = drawn.size();

   }

   for(int i=0;i<N;i++){

     deck.add(drawn.get(0));

     drawn.remove(0);

   }

 }

 public void showDeck(){

   for(Card c : deck){

     c.display();

   }

 }

}

class Test{

 public static void main(String[] args){

   Deck d = new Deck();

   System.out.println("Original deck\n");

   d.showDeck();

   d.draw(8);

   System.out.println("\nDeck after drawing 8 cards\n");

   d.showDeck();

   d.shuffle();

   System.out.println("\nDeck after shuffling\n");

   d.showDeck();

   d.restore();

   System.out.println("\nDeck after restoring cards\n");

   d.showDeck();

 }

}

<h3>Test Output:</h3>

C:\Users\hp\Desktop>java Test

Original deck

1(Club)

2(Club)

3(Club)

4(Club)

5(Club)

6(Club)

7(Club)

8(Club)

9(Club)

10(Club)

11(Club)

12(Club)

13(Club)

1(Spade)

2(Spade)

3(Spade)

4(Spade)

5(Spade)

6(Spade)

7(Spade)

8(Spade)

9(Spade)

10(Spade)

11(Spade)

12(Spade)

13(Spade)

1(Heart)

2(Heart)

3(Heart)

4(Heart)

5(Heart)

6(Heart)

7(Heart)

8(Heart)

9(Heart)

10(Heart)

11(Heart)

12(Heart)

13(Heart)

1(Diamond)

2(Diamond)

3(Diamond)

4(Diamond)

5(Diamond)

6(Diamond)

7(Diamond)

8(Diamond)

9(Diamond)

10(Diamond)

11(Diamond)

12(Diamond)

13(Diamond)

<h3>Draw action:</h3>

9(Club)

10(Club)

11(Club)

12(Club)

13(Club)

1(Spade)

2(Spade)

3(Spade)

4(Spade)

5(Spade)

6(Spade)

7(Spade)

8(Spade)

9(Spade)

10(Spade)

11(Spade)

12(Spade)

13(Spade)

1(Heart)

2(Heart)

3(Heart)

4(Heart)

5(Heart)

6(Heart)

7(Heart)

8(Heart)

9(Heart)

10(Heart)

11(Heart)

12(Heart)

13(Heart)

1(Diamond)

2(Diamond)

3(Diamond)

4(Diamond)

5(Diamond)

6(Diamond)

7(Diamond)

8(Diamond)

9(Diamond)

10(Diamond)

11(Diamond)

12(Diamond)

13(Diamond)

<h3 /><h3>Shuffling action:</h3>

12(Diamond)

8(Spade)

4(Spade)

6(Diamond)

10(Spade)

13(Club)

7(Heart)

13(Heart)

7(Diamond)

9(Heart)

11(Diamond)

5(Heart)

8(Diamond)

9(Diamond)

3(Spade)

13(Spade)

4(Heart)

2(Heart)

3(Heart)

5(Diamond)

11(Heart)

11(Club)

10(Club)

9(Club)

3(Diamond)

4(Diamond)

6(Spade)

9(Spade)

10(Heart)

11(Spade)

5(Spade)

12(Spade)

1(Spade)

6(Heart)

12(Heart)

13(Diamond)

1(Heart)

2(Diamond)

1(Diamond)

7(Spade)

12(Club)

10(Diamond)

2(Spade)

8(Heart)

  • Restore action

12(Diamond)

8(Spade)

4(Spade)

6(Diamond)

10(Spade)

13(Club)

7(Heart)

13(Heart)

7(Diamond)

9(Heart)

11(Diamond)

5(Heart)

8(Diamond)

9(Diamond)

3(Spade)

13(Spade)

4(Heart)

2(Heart)

3(Heart)

5(Diamond)

11(Heart)

11(Club)

10(Club)

9(Club)

3(Diamond)

4(Diamond)

6(Spade)

9(Spade)

10(Heart)

11(Spade)

5(Spade)

12(Spade)

1(Spade)

6(Heart)

12(Heart)

13(Diamond)

1(Heart)

2(Diamond)

1(Diamond)

7(Spade)

12(Club)

10(Diamond)

2(Spade)

8(Heart)

1(Club)

2(Club)

3(Club)

4(Club)

5(Club)

6(Club)

7(Club)

8(Club)

You can learn more about creating a class here brainly.com/question/10410845

6 0
2 years ago
A carbon composition resistor having only three color stripes has a tolerance of?
just olya [345]

Answer:

A carbon composition resistor having only three color stripes has a tolerance of 20 percent .

3 0
3 years ago
Abram needs to put multiple sets of data into the same type of calculations for different companies, so he will create a
Nesterboy [21]

Answer:

Themes, Cell Styles, Conditional Formatting, and Formulas

Explanation:

Got it right on Edg.

7 0
3 years ago
Https://forms.gle/eP8F5eKC2AUaCsB67
Deffense [45]

Answer:

NO .THATS NOT A GOOD QUESTIONS.

Explanation:THOSE R PERSONAL

3 0
2 years ago
Other questions:
  • In Linux, the most popular remote access tool is OpenSSH. Which software performs the same remote command line (CLI) access from
    7·1 answer
  • Write a program reverse-order.cpp which asks the user to input two dates (earlier date then later date). The program should repo
    13·1 answer
  • One of the most common uses of spreadsheet are
    8·1 answer
  • Cryptcat is a Linux distribution that includes hundreds of security and hacking tools, including Nessus and Metasploit. It can p
    11·1 answer
  • Which of the following best describes the basic purpose of the internet?
    11·1 answer
  • TQ Artificial Intelligence (AI)
    15·1 answer
  • What is bigger that terbites
    10·2 answers
  • Below functions flatten the nested list of integers (List[List[int]]) into a single list and remove duplicates by leaving only t
    15·1 answer
  • Can anyone help me ?
    14·1 answer
  • are you in active recovery from a substance use disorder (addiction)? active recovery is defined as being free from an alcohol o
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!