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
Why do we use main function?
Where is volatile variable stored?
What is sizeof array in c?
How can I invoke another program (a standalone executable, or an operating system command) from within a c program?
How can I write functions that take a variable number of arguments?
write a programming in c to find the sum of all elements in an array through function.
When should the const modifier be used?
What is a buffer in c?
Explain how does free() know explain how much memory to release?
How to set file pointer to beginning c?
Difference between Function to pointer and pointer to function
Why isn't it being handled properly?
write a c program to do the following: a) To find the area of a triangle. b) To convert the temperature from Fahrenheit to Celsius. c) To convert the time in hours : minutes : seconds to seconds.
What are the types of data files?
Write a program to swap two numbers without using third variable in c?