Okay something I need to know is it possible to call a value from a void function to another void function?
What I want to do is for the number value in sumTwoPrimes function and send it to void prime to check if it's prime or not and it will send back 'n' or 'y' meaning if it's not prime or is prime. including the value of i and ans. I think I put the code into this post correctly for once.
The error I get from primeAns1 and primeAns2 in the function of sumTwoPrimes is error: value not ignored as it ought to be.
ALSO: THIS is not the entire program. only the two void functions.
Code:
void prime(unsigned int &isPrime, char &primeAns)
{
unsigned int i;
if (isPrime == 0 || isPrime == 1)
{
primeAns = 'n';
}
for (i = 2; i < isPrime; i++)
{
if ((isPrime % i) == 0)
{
primeAns = 'n';
break;
}
if (i == (isPrime - 1))
{
primeAns = 'y';
}
}
}
void sumTwoPrimes(unsigned int &isPrime, char &primeAns, char&primeAns1, char &primeAns2)
{
unsigned int i;
unsigned int ans;
for (i = isPrime; i < isPrime; i--)
{
ans = isPrime % i;
primeAns1 = prime(ans, primeAns);
primeAns2 = prime(i, primeAns);
if (primeAns1 == 'y' && primeAns2 == 'y')
{
break;
}
}
}