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
miss Akunina [59]
2 years ago
13

Write a recursive function that returns 1 if an array of size n is in sorted order and 0 otherwise. Note: If array a stores 3, 6

, 7, 7, 12, then isSorted(a, 5) should return 1 . If array b stores 3, 4, 9, 8, then isSorted(b, 4) should return 0.
Computers and Technology
1 answer:
galina1969 [7]2 years ago
6 0

Answer:

The function in C++ is as follows:

int isSorted(int ar[], int n){

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

 return 1;}

if (ar[n - 1] < ar[n - 2]){

 return 0;}

return isSorted(ar, n - 1);}

Explanation:

This defines the function

int isSorted(int ar[], int n){

This represents the base case; n = 1 or 0 will return 1 (i.e. the array is sorted)

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

 return 1;}

This checks if the current element is less than the previous array element; If yes, the array is not sorted

if (ar[n - 1] < ar[n - 2]){

 return 0;}

This calls the function, recursively

return isSorted(ar, n - 1);

}

You might be interested in
For what purpose is IT used in business?
stealth61 [152]

Answer:

manufacturing

improving

customer care

transportation

human resource management

Explanation:

business communication use technology to improve their services or products as a way of gaining competitive advantage.

6 0
3 years ago
What stdio.h input function would be used to get input from the user by the keyboard? Write the code to obtain the voltage drop
torisob [31]

Answer:

scanf() function is used to get a input from keyboard.This function is in the stdio.h library.To use this function we must include the stdio.h library first in the code. Then only we can use the scanf() function in any code.printf() function is used to print anything .this function is from stdio.h library.

Code to read voltage drop across the register.

#include <stdio.h>

// main function

int main(void) {

// variable

double vr1;

printf("Enter voltage drop:");

// read  voltage drop from user

scanf("%lf",&vr1);

// print voltage drop

printf("voltage drop is:%0.2lf",vr1);

return 0;

}

Output:

Enter voltage drop:200.4                                                                                                  

voltage drop is:200.40

8 0
3 years ago
Which of the following controls computer memory?
Bogdan [553]
Operation system (OS)
4 0
3 years ago
How do you open the Font dialog?​
Simora [160]

Explanation:

Click the Home tab.

In the Fonts group, click the dialog box launcher button.

The button is found in the lower-right corner of the Font group.

The Font dialog box contains all the commands for formatting text, including quite a few that didn’t find their way into the Font group on the Ribbon. As with all text formatting, the commands you choose in the Font dialog box affect any new text you type or any selected text in your document.

When you’ve finished setting up your font stuff, click the OK button. Or click Cancel if you’re just visiting.

Use the Ctrl+D keyboard shortcut to quickly summon the Font dialog box.

hope my answer helps

pls mark this as brainlist

be sure to follow me and I will follow you back

stay safe

good day

6 0
2 years ago
What tool do windows server administrators use to create and manage user accounts?
AVprozaik [17]
Windows settings. 
1234567890
8 0
3 years ago
Other questions:
  • You were replying to e-mail when suddenly your computer started to display random messages, and stopped responding to keyboard a
    10·1 answer
  • Write the simplest statement that prints the following on a single line: 3 2 1 Go! Note: Whitespace (blank spaces / blank lines)
    11·1 answer
  • In the output at the command line from a router that reads - ip ospf message-digest-key 1 md5 CISCO-123 - what does the CISCO-12
    15·1 answer
  • A friend was just promoted to a new job that requires part-time travel, and he has also been promised a new laptop after his fir
    10·1 answer
  • Drag each tile to the correct box.
    7·2 answers
  • Discuss the DMA process​
    11·2 answers
  • he degree of operating leverage is equal to: Group of answer choices FC / OCF. VC / OCF. 1 FC / OCF. 1 VC / OCF. 1 Picture FC /
    9·1 answer
  • search engines use software that combs the web to find webpages and add new data about them to the database. what is this softwa
    5·1 answer
  • Cho lược đồ CSDL “Quản lý BÁN HÀNG” có các bảng như bên dưới. (Thuộc tính in đậm và
    7·1 answer
  • A network of computers that provides access to information on the web.
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!