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
Less than 40 percent of teens have used marijuana within the past year. True or false?
fgiga [73]
That is true. I hope this helps
6 0
3 years ago
What was the first Apple computer, and who was it designed by?
DerKrebs [107]

Answer: The first Apple Computer was Apple 1. The designer was Steve Wozniak.

Explanation: Steve Wozniak and Steve Jobs both created Apple 1. Mainly, Steve Wozniak designed it.

Hope this helps!

7 0
3 years ago
Read 2 more answers
I am programming and i want to find the amount of move functions i need to complete the full square. the square is 65 by 70 circ
Ahat [919]
Not to be rude, but this is elementary school. How would anyone know this?
8 0
4 years ago
How will 5G technology affect the current classroom? What are some concerns about 5G technology? Is 5G technology worth the risk
notsponge [240]

Answer:Death is a risk of 5g towers

Explanation:Someone caught a video of birds falling dead out of the sky because of the radiation from the 5g towers. There is enough radiation to make your eyes melt before you get close to it.

4 0
3 years ago
When adding clip art to a slide you are limited to the pictures stored on your computer?
77julia77 [94]
The answer is No.  <span>When adding clip art to a slide you are not limited to the pictures stored on your computer.  </span><span>We are not limited to using clip art from our computer. Any clip art can be used, but if it is from another source, it must first be saved to your computer as a </span>file<span>. </span>
8 0
4 years ago
Other questions:
  • On an Android device, where can a user find the correct app to use to sync contacts and apps among devices?
    10·1 answer
  • 3. You are a network administrator responsible for all network platforms and services. The Teta Company currently has only one b
    13·2 answers
  • Gemima wants to show the amount of vitamin C a fruit salad contains in the blue cell of the table below. To do this, she needs t
    9·2 answers
  • Write a program that prints the day number of the year, given the date in the form month-day-year. For example, if the input is
    9·1 answer
  • a paragraph is a segment of text with the same format that begins when you press the enter key and ends when you press enter key
    6·2 answers
  • A Cisco Catalyst switch has been added to support the use of multiple VLANs as part of an enterprise network. The network techni
    5·1 answer
  • What development first helped people shape their communities through<br> informed decisions?
    5·1 answer
  • A group of developers for a startup company store their source code and binary files on a shared open-source repository platform
    14·1 answer
  • Describe the job of an Architect.
    5·2 answers
  • Describe your ideas for a keyboarding game that would help someone improve their skills.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!