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
Which area of study involves microeconomWhich area of study involves microeconomics? A. a nation's ability to meet consumer dema
AysviL [449]

Answer:

The correct answer is C. Consumer behavior and preferences.

Explanation:

hope it will help :)

6 0
3 years ago
If a Web page is not copyright protected, then it is ethical to cut and paste sections of the page into your speech without citi
JulijaS [17]

Answer:

False.

Explanation:

Even if the web page does not have copyright protection it is unethical to cut and paste sections of the page into your speech without citing the source.It is definitely plagiarism.You are copying content from other sources and representing the mas your own.So we conclude that the answer is false.

5 0
3 years ago
What is SEO?<br> Training Live Online Instructor-Led Learning, https://www.peoplentech.com.bd/<br> ,
evablogger [386]

Answer:Search engine optimization (SEO) is the process of optimizing your online content so that a search engine likes to show it as a top result for searches of a certain keyword. ... When it comes to SEO, there's you, the search engine, and the searcher.

Explanation:

4 0
3 years ago
If a computer reboots itself on its own the computer might have a(n)
MissTica

Answer:

D. Software Problem

Explanation:

It could be that the software is bootlooping which will power on and off until its fixed.

4 0
3 years ago
What is a Caesar cipher? As part of your answer demonstrate encrypting the plaintext messages: CS IS COOL with a caesar cipher.
sweet [91]

Answer:

A Caesar Cipher is a basic encryption type.

Explanation:

Its implementation is very easy and straightforward. It uses a one-to-one of characters in a character set. The input needed is the plain-text message and the encryption number.

For example, using the character set A-Z, encrypting the text CS IS COOL using the key of 3 generates FV LV FRRO. What has been done here is to take each character in the plain-text message and move it by "encryption number steps" in the character set.

8 0
3 years ago
Other questions:
  • Web design people please help!
    7·1 answer
  • Trading your bicycle for a snowboard exemplifies ?
    15·1 answer
  • Match each item with a statement below. a device used in mobile devices to sense the physical position of the device an area whe
    11·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
  • I have $80 and I want a smartphone that you can call for free what should I get
    14·2 answers
  • __________ is a program that lets you share documents online with others.
    12·2 answers
  • Fill in the blanks with given words:{system unit / desktop / laptop / tablet / smartphone}1. A _____ can be as powerful as a des
    11·1 answer
  • During an upgrade for a new web server, Glen's company experienced a power surge. The power surge hit the new server, and now th
    10·1 answer
  • The function of the __________ is to on transmission assemble data into a frame, on reception disassemble frame and perform addr
    8·1 answer
  • Cuantos MB son 8,192 kb?​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!