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.
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 |
int swap(int *a,int *b) { *a=*a+*b;*b=*a-*b;*a=*a-*b; } main() { int x=10,y=20; swap(&x,&y); printf("x= %d y = %d\n",x,y); }
main ( ) { static char *s[ ] = {“black”, “white”, “yellow”, “violet”}; char **ptr[ ] = {s+3, s+2, s+1, s}, ***p; p = ptr; **++p; printf(“%s”,*--*++p + 3); }
main() { float f=5,g=10; enum{i=10,j=20,k=50}; printf("%d\n",++k); printf("%f\n",f<<2); printf("%lf\n",f%g); printf("%lf\n",fmod(f,g)); }
Sir... please give some important coding questions asked by product companies..
program to find the roots of a quadratic equation
14 Answers College School Exams Tests, Engineering, HP, IIIT, Infosys, Rajiv Gandhi University of Knowledge Technologies RGUKT, SSC,
how to return a multiple value from a function?
struct Foo { char *pName; char *pAddress; }; main() { struct Foo *obj = malloc(sizeof(struct Foo)); clrscr(); obj->pName = malloc(100); obj->pAddress = malloc(100); strcpy(obj->pName,"Your Name"); strcpy(obj->pAddress, "Your Address"); free(obj); printf("%s", obj->pName); printf("%s", obj->pAddress); } a. Your Name, Your Address b. Your Address, Your Address c. Your Name Your Name d. None of the above
main() { int i=_l_abc(10); printf("%d\n",--i); } int _l_abc(int i) { return(i++); }
Is this code legal? int *ptr; ptr = (int *) 0x400;
main() { float i=1.5; switch(i) { case 1: printf("1"); case 2: printf("2"); default : printf("0"); } }
struct point { int x; int y; }; struct point origin,*pp; main() { pp=&origin; printf("origin is(%d%d)\n",(*pp).x,(*pp).y); printf("origin is (%d%d)\n",pp->x,pp->y); }
#define a 10 void foo() { #undef a #define a 50 } int main() { printf("%d..",a); foo(); printf("%d..",a); return 0; } explain the answer