# C Programming – HackerRank Solution | Bouncy Number |

### (HackerRank) Write a Modular C Programming code to solve Bouncy Number, Your task is to read a number and check if it is an increasing number or decreasing number, or bouncy.

Your task is to read a number and check if it is an increasing number or decreasing number or bouncy.

A number 23456 is increasing number.

7432 is a decreasing number.

And a number 482308 is bouncy number.

Input Format

A number

Constraints

Number should be positive

Output Format

Display a message as increasing number, decreasing number or bouncy number.

Sample Input 0

23456

Sample Output 0

Increasing number

Sample Input 1

7432

Sample Output 1

Decreasing number

Sample Input 2

59213549

Sample Output 2

Bouncy

CODE:

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

void number(int n)
{
int dig,copy,max=0,min=9999,status=0;
while(n!=0)
{
dig=n%10;
copy=dig;
if(copy>max)
{
max=copy;
status=1;
}
else if(copy<min)
{
min=copy;
status=2;
}
else
{
status=0;
}
copy=0;
dig=0;
n=n/10;

}
if(status==1)
printf("Decreasing number\n");
else if(status==2)
printf("Increasing number\n");
else
printf("Bouncy\n");
}
int main()
{
int n;
scanf("%d",&n);
if(n<0)
{
printf("Invalid number\n");
}
else
number(n);
return 0;
}

OUTPUT

Congratulations, you passed the sample test case.

Click the Submit Code button to run your code against all the test cases.

Input (stdin)

23456

Increasing number
Expected Output

Increasing number

Please find some more codes of Loops, Condition Statements, 1D Arrays, 2D Arrays, Strings, Pointers, Data Structures, Files, Linked lists, MISC, Solved model question papers & Hacker Rank all solutions on the below page:

Top 100+ C Programming codes – KLE Technological University