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

String copy logic in one line.

11 Answers   Microsoft, NetApp,


Write a c program to search an element in an array using recursion

1 Answers   Wipro,


How will u find whether a linked list has a loop or not?

8 Answers   Microsoft,


programming in c lanugaue programm will errror error with two header file one as stdio.h and other one is conio.h

1 Answers  


how to concatenate the two strings

1 Answers  






main() { char a[4]="HELLO"; printf("%s",a); }

3 Answers   CSC,


Write a routine that prints out a 2-D array in spiral order

3 Answers   Microsoft,


void main() { int *i = 0x400; // i points to the address 400 *i = 0; // set the value of memory location pointed by i; }

2 Answers  


Write a program to receive an integer and find its octal equivalent?

7 Answers  


main() { int x=5; clrscr(); for(;x==0;x--) { printf("x=%d\n”", x--); } } a. 4, 3, 2, 1, 0 b. 1, 2, 3, 4, 5 c. 0, 1, 2, 3, 4 d. none of the above

3 Answers   HCL,


Print an integer using only putchar. Try doing it without using extra storage.

2 Answers  


enum colors {BLACK,BLUE,GREEN} main() { printf("%d..%d..%d",BLACK,BLUE,GREEN); return(1); }

2 Answers  


Categories