I'm stuck in a simple question of C++ but this has been tough for me now. Can anybody help me out with this issue.
I have written C++ code for the problem i know that code cannot print out as the question's answer But i don't know how to solve it now.
The code is as below:
#include<iostream.h>
#include<conio.h>
long int* solve10();
void main()
{
clrscr();
long int* solveten;
cout<<"Solve for ten is x factorial + y factorial equals factorial of 10"<<endl;
solveten=solve10();
cout<<"The first value is x and the second is y:"<<endl;
cout<<"The value x and the value y are:"<<endl;
for(int i=0;i<=1;i++){
cout<<*(solveten+i)<<endl;
}
getch();
}
long int* solve10(){
static long int a[2];
int k=1,x=1,l=1,y;
long int mul=1;
for(int i=1;i<=10;i++){
mul=mul*i;
}
do
{
k=x*k;
for(y=1;y<=10;y++){
l=l*y;
if((k+l)==mul){
a[0]=x;
a[1]=y;
}
}
x++;
}while(x<=10);
return a;
}
What will be its best answer??