There is a lucky draw held every day.
if there is a winning number eg 1876,then all possible
numbers like 1867,1687,1768 etc are the numbers that match
irrespective of the position of the digit.
Thus all these numbers qualify fr the lucky draw prize
Assume there is no zero digit in any numbers.
write a program to show all the possible winning numbers if
a "winning number"is passed as an arguments to the function.



There is a lucky draw held every day. if there is a winning number eg 1876,then all possible numb..

Answer / guest



void main()
{
int sum=0,mul=1,s=0,m=1,i,t,nn,j=1;
clrscr();

printf("Enter number without '0' as its digit
\n");
scanf("%d",&nn);

while(nn>0)
{
sum=sum+(nn%10);
mul=mul*(nn%10);
nn=nn/10;
j=j*10;
}

printf("j %d sum %d mul %d",j,sum,mul);


for(i=j/10;i<j;i++)
{ t=i;
while(t>0)
{
s=s+(t%10);
m=m*(t%10);
t=t/10;
}
if(s==sum && mul==m)
printf("\n%d",i);
s=0;
m=1;
}

getch();

}

Is This Answer Correct ?    11 Yes 2 No

Post New Answer

More C Code Interview Questions

Write a function to find the depth of a binary tree.

13 Answers   Adobe, Amazon, EFI, Imagination Technologies,


1. const char *a; 2. char* const a; 3. char const *a; -Differentiate the above declarations.

3 Answers  


int i,j; for(i=0;i<=10;i++) { j+=5; assert(i<5); }

3 Answers   Cisco, HCL,


why nlogn is the lower limit of any sort algorithm?

1 Answers  


main() { char *str1="abcd"; char str2[]="abcd"; printf("%d %d %d",sizeof(str1),sizeof(str2),sizeof("abcd")); }

1 Answers  


Who could write how to find a prime number in dynamic array?

1 Answers  


#include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }

1 Answers  


#include <stdio.h> #define a 10 main() { #define a 50 printf("%d",a); }

2 Answers  


1) int i=5; j=i++ + i++ + i++; printf("%d",j);This code gives the answer 15.But if we replace the value of the j then anser is different?why? 2)int i=5; printf("%d",i++ + i++ + i++); this givs 18.

8 Answers   IBPS, Infosys, TCS,


Develop a routine to reflect an object about an arbitrarily selected plane

1 Answers  


how many processes will gate created execution of -------- fork(); fork(); fork(); -------- Please Explain... Thanks in advance..!

8 Answers   GATE,


main() { char *p = “ayqm”; printf(“%c”,++*(p++)); }

29 Answers   IBM, TCS, UGC NET, Wipro,


Categories