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
White raven [17]
3 years ago
15

Write a recursive function that returns true if the digits of a positive integer are in increasing order; otherwise, the functio

n returns false. Also, write a program to test your function.

Computers and Technology
1 answer:
deff fn [24]3 years ago
4 0

Answer:

C code implementing the function:

#include<stdio.h>

int isIncreasing(int m);

void main()

{

int y, t;

 

printf("Enter any positive integer: ");  

scanf("%d", &y);

 

t= isIncreasing(y); //call the functoion isIncreasing(int m)  

 

if(t==1) //if isIncreasing(int m) returns 1, then the digits are in //increasing order

 printf("True:  The digits are in increasing order");

else

 printf("False:  The digits are not in increasing order");

}

int isIncreasing(int m)

{

int d1,d2;

if(m/10==0) //if we reach till the left of left most digit, then all before  //digits were in order. else it won't go upto that.

{

 return 1;

}

d1 = m%10; //d1 holds the right most digit of current m.

if(m%10 !=0)

{

 m = m/10; //m is updated to find the rest digits and compare //them.

 d2 = m%10;//d2 holds the digit just left of the right most digit of //m.

 if(d2 <= d1) // if the right most and it's left digits are in order then //we proceed to left.

 {

  isIncreasing(m);

 }

 else   //else we stop there itself, no need to move further.

  return 0;

}

}

output is given as image.

You might be interested in
What is the difference between a network intrusion detection system (NIDS) and a network intrusion prevention system (NIPS)?
alisha [4.7K]

Answer:

Detection vs Prevention

Explanation:

  • A Network Intrusion Detection System as the name suggests it "detects" the attackers / vulnerabilities existed in the network system / infrastructure.
  • A Network Intrusion Prevention Detection System as the name suggests it "prevents" the attackers from hacking the system. While a detection just detects the abnormalities where as a prevention system can prevent them.
  • The detection system detects the vulnerabilities, security threats and the attackers in the system through the web traffic analyzers and security analyzers.
  • The prevention system prevents the network from being compromised. It tries to regain the access if already compromised.
  • Both the NIDS and NIPS have to be coordinated for the full protection of the network.
8 0
3 years ago
What HTML tag would you use to indicate a line break?
DIA [1.3K]

Answer:

<br> APEX Verified

Explanation:

8 0
3 years ago
Write the simplest statement that prints the following on a single line: 3 2 1 Go! Note: Whitespace (blank spaces / blank lines)
Olin [163]

Answer:

//here is the statement in java.

import java.util.*;

//class definition

class Solution

{

// main method of the class

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

{

   try{

    // this statement will print the 3 2 1 Go! and go to newline

       System.out.println("3 2 1 Go!");

   }catch(Exception ex){

       return;}

}

}

Explanation:

We can use "System.out.println()" to print the required output same as it required. After printing this, it will go to newline.

Output:

3 2 1 Go!

4 0
3 years ago
Which of the following is a safe work practice to protect you from electrocution hazards?
Flura [38]
What are the answer choices?
7 0
3 years ago
Data values in a program are held in _________. a data types b names c variables d lockers
Tpy6a [65]

Answer:

Answered below

Explanation:

Data values in a program are held in variables. Variables are like containers for holding different types of data. A variable can be identified depending on the kind of data it holds. Variables can hold data types of integers, strings, arrays, lists, sets, Boolean etc. They hold unique data types and a can not hold different data types. Different rules exist for naming variables in different programming languages. A variable name should start with lowercase letters and be descriptive of the data it holds.

7 0
3 years ago
Other questions:
  • Letm1, m2,···mnbe distinct numbers on the number line, in the increasing order. Your goalis to color all of them blue. You have
    9·1 answer
  • A terrible new disease, HORSEVID, has begun to spread among horses worldwide. Stable manager Jimmy is trying to take as many pre
    5·1 answer
  • The destructor automatically executes when the class object goes out of ____.
    12·1 answer
  • Kelly is a college sophomore majoring in computer science. She is interested in gaining exposure to the most useful and current
    13·1 answer
  • When the code that follows is executed, a message is displayed if the value the user entersvar userEntry = (prompt("Enter cost:"
    11·1 answer
  • 2 Manter o autocontrole nos ajuda a evitar muitos problemas na nossa vida pessoal e no ambiente profissional. Em se tratando de
    14·1 answer
  • Briefly explain specialisation?​
    11·1 answer
  • An EULA usually takes the form of an electronic notification that appears when installing software. The user then has a choice t
    14·1 answer
  • Which of the following has the greatest impact on telecommunications design?
    12·2 answers
  • I need a solution for this problem asap.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!