Write a program to print nos between 100 and 500 which should print nos having 3 different digitsfor eg:it should print :123,159,342 etc all have different digits...but not 121, 122,333, see here atleast 2 digits are equal

Showing Answers 1 - 23 of 23 Answers

char h;

char t;

char o;

for (int i = 100; i <= 500; i++)

{

string x = Convert.ToString(i);

h = x[0];

t = x[1];

o = x[2];

if (h != t && h != o && t != o)

{

Console.WriteLine(i);

}

}

  Was this answer useful?  Yes

Preetham

  • Oct 6th, 2006
 

#include<stdio.h>

#include<conio.h>

void main()

{

int a,b,c,d,k,f;

clrscr();

printf("Enter the range n");

scanf("%d %d",&a,&b);

for(c=a;c<b;c++)

{

k=c;

d=k%10;

k=k/10;

f=k%10;

k=k/10;

if(d!=k && k!=f && d!=f)

printf("%d", c);

}

getch();

}

  Was this answer useful?  Yes

umeshknair

  • Oct 7th, 2006
 

Hello trY this one too

for(n=100; n<500; n++)
{
 d1=n/100;
 d2=n/10-10;
 d3=n%10;

 if(d1==d2 || d1==d3 || d2==d3) continue;

 printf("%d ", n);
}

-dot-

  Was this answer useful?  Yes

Vinod

  • Oct 12th, 2006
 

#includeint main(){ int a,b,c; int z=0; for(a=1;a<5;a++) { for(b=0;b<10;b++) { if( b != a ) { for(c=0;c<10;c++) { if( (c != b) && (c != a) ) { z = (a*100) + (b*10) + c ; printf("n%d",z ); } } } } }}

  Was this answer useful?  Yes

Debasis Biswal

  • Oct 30th, 2006
 

Actually this is the correct oneint n,d1,d2,d3;for(n=100; n<500; n++){ d1=n/100; d2=n/10-(d1*10); d3=n%10; if(d1==d2 || d1==d3 || d2==d3) continue; cout<

  Was this answer useful?  Yes

manik sheeri

  • Nov 7th, 2006
 

the number should not be divisible by 111

  Was this answer useful?  Yes

kaushalgoa

  • Dec 31st, 2007
 

int main()
{
    int start = 100,end = 500;
    int x = 0, a = 0, b = 0, c = 0;

    for(x = start; x <= end; x++)
    {
        a = x/100;        
        b= (x%100)/10;
        c = (x%100)%10;

        (a == b)? 0 :(b == c)? 0 :(a == c) ? 0 :printf("%dn",x);;  // in one line.
                
    }
    return 0;
}

  Was this answer useful?  Yes

// This program will work for any Range of integer values.
int main()
{
 int i,j,k,n1,n2,n3;
 int a,b,count = 0,var1,i1,i2,arr[100];
 int found = 0;
 printf("Enter the Rangen");
 scanf("%d %d",&a,&b);

 printf("nThe values arenn");
 for(i=a;i<=b;i++)
 {
  k = i;
  count = 0;

  while(k!=0)
  {// This part is used to find the number of digits present in the given number
   k = k / 10;
   count++;
  }
     k = i;
  for(var1 = count;var1 >= 1 ; var1--)
  {// This part is used to store each digit in array format
   // for ex : for the number 123 arr[1] = 1, arr[2] = 2, arra[3] = 3.
         arr[var1] = k % 10;
   if(k != 0)
      k = k / 10;
  }
  //This part is used to check for the Repetition
  for(i1=1;i1<count;i1++)
  {
   for(i2 = i1+1; i2<= count;i2++)
   {
    if(arr[i1] == arr[i2])
     found = 1;
   }
  }
  if(found == 0)
  {
   printf("%dn",i);
  }
  else
   found = 0;
 }
 printf("n");
 return 1;
}

  Was this answer useful?  Yes

#include<stdio.h>
int main(){
    int a,b,c;
    for(a=1;a<5;a++)
        for(b=0;b<10;b++)
        for(c=0;c<10;c++)
            if(c!=a&&c!=b&&a!=b)
                printf("%d ",((a*10)+b)*10+c);
    return 1;
}

  Was this answer useful?  Yes

#include<stdio.h>
main()
{
int num=101,temp,t,t1,t2;
while(num>100&&num<500)
{
temp=num;

t=temp%10;
temp=temp/10;
t1=temp%10;
temp=temp/10;
t2=temp%10;
temp=temp/10;
if((t==t1)||(t1==t2)||(t2==t))
{
num++;
continue;
//num++;
}
else
{
printf("%dn",num);
num++;
}
}
}

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions