the number 138 is called well ordered number because the
three digits in the number (1,3,8) increase from left to right
(1<3<8). the number 365 is not well ordered coz 6 is larger
than 5.
write a program that wull find and display all possible
three digit well ordered numbers.

sample:
123,124,125,126,127,128,129,134
,135,136,137,138,139,145,146,147
148
149,156.......789

Answer Posted / ankit kamboj

#include<stdio.h>
main()
{
int i,j,n,a,n1,cnt=0;;

int arr[3];
for(n=100;n<=999;n++)
{ n1=n;
for(i=2;i>=0,n1>0;i--,n1=n1/10)
{ a=n1%10;
arr[i]=a;
}

for(i=0;i<3;i++)
printf("%d ",arr[i]);

if(arr[0]<arr[1] && arr[1]<arr[2])
{printf("It is well ordered \n"); cnt++;}
else
printf("It is not well order\n");

}
printf("The n0. of well ordered no. are %d\n",cnt);
}

Is This Answer Correct ?    6 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the best way to comment out a section of code that contains comments?

782


Why does notstrcat(string, "!");Work?

642


please send me the code for multiplying sparse matrix using c

1725


C language questions for civil engineering

1239


What is indirection? How many levels of pointers can you have?

657






can anyone suggest some site name..where i can get some good data structure puzzles???

1643


Explain how do I determine whether a character is numeric, alphabetic, and so on?

652


What is extern variable in c with example?

538


Tell me about low level programming languages.

642


Write a program to swap two numbers without using a temporary variable?

607


What is the difference between fread and fwrite function?

640


Mention four important string handling functions in c languages .

624


Can we add pointers together?

616


find the value of y y = 1.5x+3 for x<=2 y = 2x+5 for x>2

1526


What is #define?

575