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
Rus_ich [418]
3 years ago
13

5-11) (Find the Smallest Value) Write an application that finds the smallest of several integers. Write a program which first as

ks the user to enter the number of values to enter, then asks for each value, and finally prints out the lowest value of those entered.
Computers and Technology
1 answer:
Elanso [62]3 years ago
8 0

Answer:

import java.util.Arrays;

import java.util.Scanner;

public class num4 {

   public static void main(String[] args) {

   Scanner in = new Scanner(System.in);

       System.out.println("How many numbers? ");

       int n = in.nextInt();

       int []intArray = new int[n];

       //Entering the values

       for(int i=0; i<intArray.length;i++){

           System.out.println("Enter the numbers");

           intArray[i]=in.nextInt();

       }

       System.out.println(Arrays.toString(intArray));

       int min =intArray[0];

       for(int i =0; i<intArray.length; i++){

           if(min>intArray[i]){

               min = intArray[i];

           }

       }

       System.out.println("The Minimum of the numbers is "+min);

   }

}

Explanation:

  • Using Java programming language
  • Prompt the user for the number of values
  • Using Scanner class receive and store in a variable
  • Create an array of size n
  • Using an for loop continuously ask the user to enter the integers
  • Print the array of integers
  • Using another for loop with an if statement, find the smallest element in the array of numbers
  • Output the the smallest number
You might be interested in
Write a parent program to fork(2) n processes where n is passed tothe program on the command line, and n can be from 1 to 10. Al
MrRissso [65]

Answer:

Complete code is given below:

Explanation:

#include <stdio.h>

#include <sys/types.h>

#include <unistd.h>

#include <time.h>

#include <sys/wait.h>

int main(int argc , char *argv[]){

pid_t mypid, childpid;

int status;

int i,n;

time_t t;

     

mypid = getpid();

printf("pid is %d.\n", mypid);

childpid = fork();

if ( childpid == -1 ) {

perror("Cannot proceed. fork() error");

return 1;

}

 

 

if (childpid == 0) {

 

 

mypid = getpid();

 

 

childpid = fork();

if ( childpid == -1 ) {

perror("Cannot proceed. fork() error");

return 1;

}

 

if (childpid == 0) {

 

mypid = getpid();

printf("Child pid is %d.\n", getppid());

 

childpid = fork();

 

 

if ( childpid == -1 ) {

perror("Cannot proceed. fork() error");

return 1;

}

random((unsigned) time(&t));

printf(" parent id = %d : Random = %d\n",mypid , (int)(random()% 100 +1));

printf("child id = %d : Random = %d\n",getpid , (int)(random()% 100 +1));

 

if (childpid == 0) {

 

printf("Child 2: I hinerited my parent's PID as %d.\n", mypid);

 

mypid = getpid();

printf("Child 2: getppid() tells my parent is %d. My own pid instead is %d.\n", getppid(), mypid);

 

sleep(30);

return 12;

} else return 15;

} else {

 

while ( waitpid(childpid, &status,0) == 0 ) sleep(1);

 

if ( WIFEXITED(status) ) printf("Child 1 exited with exit status %d.\n", WEXITSTATUS(status));

else printf("Child 1: child has not terminated correctly.\n");

}

} else {

printf(" fork() is ok and child pid is %d\n", childpid);

wait(&status);

 

if ( WIFEXITED(status) ) printf(" child has exited with status %d.\n", WEXITSTATUS(status));

else printf(" child has not terminated normally.\n");

}

 

return 0;

}

Output:

pid is 24503.

Child   pid  is 24565.

parent id = 24566 : Random = 87

child id = 1849900480 : Random = 78

pid is 24503.

Child 1  exited with exit status 15.

pid is 24503.

fork() is ok and child pid is  24565

child has exited with status 0.

6 0
3 years ago
Nila has created a report, and now she would like to a create table of contents. Nila has reviewed her report and decides to add
Alenkinab [10]

Answer:

The answer is "heading"

Explanation:

Headings, which appear into your document must be marked simply, objectively and correctly because it shows the final report structure and enable to easy access with specific information.  

  • It also promotes to read the document. So, its consistency is ensured in the headings.
  • In sort documents, it can't require any heading, but it Nila created a report, in which she requires  heading and then she update the content of the tables, and other choices can't be described in the given scenario, that's why it is correct
5 0
3 years ago
Your wearable device synchronized with your smartphone this morning when you turned it on, but the two devices no longer are syn
Lady_Fox [76]
<span>There are several reasons why two devices are not synchronized: maybe there are not the same versions of the programs on both devices, maybe the software needs restart in order to have the latest input data, maybe the internet connection was lost during synchronization

Next steps would be:
- restart the devices
- Update to the latest version
- connect to the internet
- make the synchronization again
</span>
7 0
2 years ago
What was the first computer to defeat a world champion chess player?
deff fn [24]
deep blue IBM's chess-playing computer
6 0
3 years ago
Choose the 3 Points in good story telling
Sidana [21]

Answer:

1.Choose a clear central message 2. Embrace conflict 3.Have a clear structure  

Explanation:

8 0
2 years ago
Other questions:
  • An _________ is a phrase formed from the first letters of words in a set phrase or series of words a. Acronymic sentence c. Basi
    7·2 answers
  • What computer has best software
    5·1 answer
  • 13. You're expecting an important call from Mr. Suarez, a potential customer. While waiting for this call, your supervisor calls
    15·1 answer
  • What type of identity theft occurs when a thief spends another person's money or opens a line of credit in their name?
    8·2 answers
  • Explain how it is possible for a sequence of packets transmitted through a wide area network to arrive at their destination in a
    14·1 answer
  • All living organisms make up the (4 points)
    8·1 answer
  • Which two options are negotiated via ncp during the establishment of a ppp connection that will use the ipv4 network layer proto
    7·1 answer
  • Please tell fast plzzzzzzzzzzz.​
    9·1 answer
  • If there are over 1,000 websites about a certain topic, the information is reliable. A. True B. False
    12·1 answer
  • Many people are scared of the rise of Artificial Intelligence (AI). Do you think computers that are controlled by an AI are some
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!