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 job title of someone who works with video and/or film?
boyakko [2]
Producer, videographer
4 0
4 years ago
Where is voice data stored in Android?
Dafna1 [17]
Inside its internal hard-drive and your google account!
8 0
3 years ago
Why do people enjoy codehs
Alex73 [517]

Answer: this is a moral question, but here is my view

Explanation:

we get to learn about things like java which i am currently learning for AP computer science A

6 0
3 years ago
Where should citations be included in your research paper? Select all that apply.
yKpoI14uk [10]

Answer:

it would be the first one because it's the header and that's what applies

5 0
3 years ago
An independent frame that holds a program, document, or folder contents in windows 7 is called a ____.
svetlana [45]
Window.

Have a wonderful day!~
7 0
4 years ago
Other questions:
  • What is the data rate of a DS0 signal?
    10·1 answer
  • Consider the concept of cultural lag. Identify two American values that are “lagging.” What are three norms that are lagging? Ho
    11·1 answer
  • Visit the target Let Me Discover page and review the history of HTML. Also, search the internet for the history of the internet
    12·1 answer
  • The ____ aggregate function finds the largest value
    10·1 answer
  • ____ the styles allows the designer to start from a known baseline, confident that no unwanted styles will creep in from any bro
    6·1 answer
  • Answer this question for points lol
    7·2 answers
  • PLZZZZ help will give brainlest
    5·1 answer
  • Part 2: Code the Program
    12·1 answer
  • Aurelia is designing a user interface for a new game app. Which of the following should she taken into consideration for the use
    7·1 answer
  • Summary about Interface Design in system analysis
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!