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
juin [17]
4 years ago
8

An array is sorted (in ascending order) if each element of the array is less than or equal to the next element .

Computers and Technology
1 answer:
Aleks04 [339]4 years ago
8 0

Answer:

// The program below checks if an array is sorted or not

// Program is written in C++ Programming Language.

// Comments are used for explanatory purpose

//Program Starts here

#include<iostream>

using namespace std;

//Function to check if the array is sorted starts here

int isSorted(int arr[], int count)

{

// Check if arrays has one or no elements

if (count == 1 || count == 0) {

return 1;

}

else

{

// Check first two elements

if(arr[0] >= arr[1])

{

return 0; // Not sorted

}

else

{ // Check other elements

int check = 0;

for(int I = 1; I<count; I++){

if (arr[I-1] > arr[I]) { // Equal number are allowed

check++; // Not sorted

}

}

}

if(check==0)

return isSorted(arr, count - 1); //Sorted

else

return 0; // Not sorted

}

// Main Method starts here

int main()

{

int count;

cin<<count;

int arr[count];

for(int I = 1; I<=count; I++)

{

cin>>arr[I-1];

}

int n = sizeof(arr) / sizeof(arr[0]);

if (isSorted(arr, n))

cout << "Array is sorted";

else

cout << "Array is not sorted";

}

You might be interested in
___________ is some danger that can exploit a vulnerability.
andreyandreev [35.5K]

<u>Threat </u>is some danger that can exploit a vulnerability.

<h3>What is Threat?</h3>

Threat  is seen as Anything that can be able to take advantage of a vulnerability, intentionally as well as  accidentally, and take or damage, the  asset of a person.

Note that a threat is that which a person or firm is protect against and Vulnerability is seen as Weaknesses.

Therefore, <u>Threat </u>is some danger that can exploit a vulnerability.

Learn more about vulnerability from

brainly.com/question/25633298

#SPJ1

8 0
2 years ago
How many iterations for each for-loop where max = 10 and incr = 3 a. for (int i = 0; i &lt; max; i++) b. for (int i = 0; i &lt;
LekaFEV [45]

Explanation:

Answer to the following iterations are:

a)

In the following for-loop, the loop will starts from 0 and end at 9.

for example:

0 1 2 3 4 5 6 7 8 9

So, the loop will iterate 0-9, which means 10 times.

b)

In the following for-loop, the loop will starts from 0 and end at 8 but in the gap of 2 because of the increment of 2 in the variable "i".

for example:

0 2 4 6 8

So, the loop will iterate even times or 5 times, which means 0 2 4 6 8.

c)

In the following for-loop, the loop will starts from 0 and end at 9 but in the gap of 3  because of the increment of 3 in the variable "i" and the value is assign in the variable "incr" is 3.

for example:

0 3 6 9

So, the loop will iterate 4 times, which means 0 3 6 9.

d)

In the following for-loop, the loop will starts from 3 and end at 9 but in the gap of 3  because of the increment of 3 in the variable "i" and the value is assign in the variable "incr" is 3.

for example:

3 6 9

So, the loop will iterate 3 times, which means 3 6 9.

e)

In the following for-loop, the loop will starts from 10 and end at 1 which means reverse order.

for example:

10 9 8 7 6 5 4 3 2 1

So, the loop will iterate 10-1, which means 10 times in reverse order.

f)

In the following for-loop, the loop will not works because of the condition which is i is less than 0 but in the following code loop will starts from 3.

So, that's why loop will not iterate.

g)

In the following for-loop, the loop will starts from 1 and end at 9 but in the multiple of 3  because the variable "i" will multiply by the variable "incr" and the value is assign in the variable "incr" is 3.

for example:

1 3 9

So, the loop will iterate 3 times, which means 1 3 9.

h)

In the following for-loop, the loop is the infinite loop because of the condition which is i is less than max but and the loop will starts from 0 and goes on infinite times.

So, that's why it is the infinite loop.

4 0
3 years ago
What type of program would you use to create a personal budget?
Rina8888 [55]

Answer:

Using a spreadsheet would be the best program for creating a personal budget.

Explanation:

With a spreadsheet, you can enter formulas to add or subtract from your budget, plus you can create charts and graphs as well.

8 0
2 years ago
What does a compiler do, and why is it necessary when using higher-level languages?
UkoKoshka [18]

Answer:

A compiler converts human readable instructions into machine code (machine readable instructions). Without it, a computer will not be able to understand the code that was written and execute it. Since higher programmer languages are easier for humans to read and write and effective compiler is needed. This has to do with how the compiler does much of the work when it comes to programming.

A great example is a drag and drop programming language. The compiler does all the work in the background before the machine can actually execute the code, but the language itself is incredibly easy to read and write by human standards. Without the compiler, it would be impossible for the machine to execute any code.

Explanation:

High Level programming languages like Python has a system that turns our easy to read human code into something the computer can actually read. Python for example, doesn't compile the code as it was design to do it as it runs.

Low level programming languages like Objective C uses a compiler to change the human readable code to machine code. You can tell a compiler was used when there is a 2nd file, one that can't be read by humans. This is the compiled code that the machine actually runs.

8 0
3 years ago
Which data type or collection of data types can SOQL statements populate or evaluate to?
Artyom0805 [142]

Answer:

The answer is "Option A, Option B, and Option D".

Explanation:

"Salesforce Object Query Language" is a SOQL. It is used to scan for specific information in your company's salesforce records. A single object, an integer and several data types of objects are used in this declaration and other options wrong that can be described as follows:

  • In option C, It is wrong because in archiving it is not to help to classify data completely.
  • In option E, boolean data type is used for given only true or false value that's why it is not correct.
5 0
3 years ago
Other questions:
  • Imagine you are writing a personal fitness program that stores the user's age, gender, height (in feet or meters), and weight (t
    10·1 answer
  • Which of the following is small Java code script that adds functionality to web pages in a browser?
    7·1 answer
  • Two electronics technicians are measuring electrical quantities in circuits. Technician A says that copper, glass, porcelain, an
    13·2 answers
  • Which is the correct process for inserting a blank worksheet?
    11·2 answers
  • Program 1: I’m buyin’ a Ferrari! If you’ve ever travelled to another country, you know that working with different currencies ta
    6·1 answer
  • A(n) ____________________ is a named collection of stored data, instructions, or information and can contain text, images, video
    5·2 answers
  • Ten examples of an interpreter
    8·1 answer
  • Any song recommendations, pls dont say 6ix9ine or lil pump
    5·2 answers
  • Six security issues and six descriptions are shown below.
    11·1 answer
  • Consider some of the widespread global issues that we face here on Earth and briefly describe them. Then, choose one of the spac
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!