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
kotykmax [81]
3 years ago
12

write a function issorted() that accepts an array of real numbers arr and an integer n as arguments, where n is the size of arr.

The function properly reads n integers into the array arr,then finds and returns whether the items of the array are sorted in ascending order.
Computers and Technology
1 answer:
lesantik [10]3 years ago
7 0

Answer:

Here is code in java.

import java.util.*;

class Main

{

//main method of the class

public static void main (String[] args) throws java.lang.Exception

{

   try{

       int m;

        // scanner object to read input from user

       Scanner ss=new Scanner(System.in);

       System.out.println(" size  of the array:");

       //read the size of the array

        m=ss.nextInt();

        // create array of the given size

        float arr[]=new float[m];

        /* call function to check whether input are in the ascending sorted order or not */

        Boolean res= issorted(arr,m);

       

      // print the result

       System.out.println("array in the ascending sorted order  : "+res);

     

       

   }catch(Exception ex){

       return;}

}

 // function to check whether input are in the ascending sorted order or not

public static boolean issorted(float[] arr,int n)

{

    int i,j;

    float d;

    Boolean flag=true;

    Scanner ss=new Scanner(System.in);

    System.out.println("enter the elements of the array:");

     // read elements of the array

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

    {

        arr[i]=ss.nextFloat();

    }

   

    // check elements re in the ascending order or not

    for(j=0;j<n-1;j++)

    {

        if(arr[j]>arr[j+1])

        {

            flag=false;

            break;

        }

    }

     // return the result

    return flag;

}

}

Explanation:

With the help of scanner class object, read the size "m" of array.Create an array of  the given size. Pass array and integer into the function issorted(). Read the elements of the array and then check elements are in the ascending order or not.It will return "true" if elements are in the sorted order else it will return "false".

Output:

enter  size  of the array:                                                                                                                                    

5                                                                                                                                                              

enter the elements of the array:                                                                                                                              

1 2 3 4 7                                                                                                                                                      

array in the ascending sorted order  : true                                                                                                                              

enter  size  of the array:                                                  

5                                                                            

enter the elements of the array:                                              

2 4 9 3 5                                                                  

array in the ascending sorted order  : false

You might be interested in
Some financial institutions can be really bad about putting unexpected charges
kherson [118]
I think it’s false ............
7 0
3 years ago
01:24:3
bogdanovich [222]

Answer:

1. Uncompressed audio formats

2. Formats with lossless compression

3. Formats with lossy compression

Explanation:

1. Uncompressed audio formats, such as WAV, AIFF, AU or raw header-less PCM;

2. Formats with lossless compression, such as FLAC, Monkey's Audio (filename extension .ape), WavPack (filename extension .wv), TTA, ATRAC Advanced Lossless, ALAC (filename extension .m4a), MPEG-4 SLS, MPEG-4 ALS, MPEG-4 DST, Windows Media Audio Lossless (WMA Lossless), and Shorten (SHN).

3. Formats with lossy compression, such as Opus, MP3, Vorbis, Musepack, AAC, ATRAC and Windows Media Audio Lossy (WMA lossy).

8 0
3 years ago
Describe two ways in which an organizer can assist in taking notes
FromTheMoon [43]

There are two ways in which an organizer can assist in taking notes:

1. It helps one make connections between different topics. (concept maps are really good for this)

2. It allows one to identify the main topics and subtopics. (outlines are great for this purpose)

6 0
2 years ago
Read 2 more answers
A restaurant is a workplace for someone whose career specialty is in
Rashid [163]
A restaurant is a workplace for someone whos career specialty is in... Cooking

The answer is: Cooking
3 0
3 years ago
Read 2 more answers
Describe an application where a parallel circuit might work better than a series circuit
Mama L [17]
An application where you would prefer a parallel circuit over series would be a string of Christmas lights. If the light string is wired in parallel, when one bulb burns out, it would not effect the red of the string.
6 0
3 years ago
Read 2 more answers
Other questions:
  • Regarding an intrusion detection system (IDS), stateful matching looks for specific sequences appearing across several packets i
    9·1 answer
  • From the video "Your Password Sucks", using computer power to guess your password by trying multiple variations one after the ot
    15·2 answers
  • How can you create the first row of the table as the header of the table?
    14·2 answers
  • Tower Building Activity
    12·1 answer
  • Which grapgic element loads faster when used with text or audio
    7·1 answer
  • Convert 15 from decimal to binary. Show your work.
    14·1 answer
  • What type of Internet monitoring technique records information about a customer during a web surfing session, such as what websi
    8·1 answer
  • You are the head of the corporate security department, and the Microsoft teamhas asked you for some assistance in setting the pa
    11·1 answer
  • Which situations are better suited to an indefinite (while) loop? Select 3 options.
    5·2 answers
  • Which type of document should Omar print?
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!