Here is the assignment and then I wil post what I have.
For each pair of primes between 2 and 100 inclusive (EVERYCOMBINATION – NO DUPLICATES) check if the sum of the pair plus one is prime.Below is an example of what the results of the calculations should be, NOT theactual sample output. DO NOT PRINT THIS IN YOUR PROGRAM:
The sum of 2 and3 plus 1 is 6, which is NOT a prime number
The sum of 2 and5 plus 1 is 8, which is NOT a prime number
[SIZE=2][COLOR=#000000] The sum of 2 and7 plus 1 is 10, which is NOT a prime number
and then
[SIZE=3][FONT=Times New Roman] For every number from 500 to 600 inclusive, use pullDigitto obtain the first and second digits of the number. Combine these two digitsback into a single two digit number and sum it with the third digit of theoriginal number. Check if this result is prime.
I have to use 5 functions in the program for some reason
sumofextremes,productofextremes, printResults, isPrime, and pulldigit.
Heres what I have so far
Code:
#include <stdio.h>
#include <math.h>
#include #include <stdio.h>
#include <math.h>
#include <limits.h>
int flag;
int productOfExtremes(int,int,int);
int sumOfExtremes(int,int,int);
int minimum(int,int,int);
int maximum(int,int,int);
int isPrime(int);
int primecombo(int);
int main()
{
return 0;
}
int sumOfExtremes(int a, int b, int c)
{
int sumOF;
sumOF=maximum(a,b,c)+minimum(a,b,c);
return sumOF;
}
int maximum(int a, int b, int c)
{
int maximum;
maximum=INT_MIN;
if(maximum<a)
maximum=a;
if(maximum<b)
maximum=b;
if(maximum<c)
maximum=c;
return maximum;
}
int minimum(int a, int b, int c)
{
int minimum;
minimum=INT_MAX;
if(minimum>a)
minimum=a;
if(minimum>b)
minimum=b;
if(minimum>c)
minimum=c;
return minimum;
}
int productOfExtremes(int a, int b, int c)
{
int productOF;
product=maximum (a,b,c)*minimum (a,b,c);
return productOF;
}
int isPrime(int a)
{
int isPrime;
if(a==1 || a==0 || a==3)
return 1;
else
{
if(!(a&1))
return 0;
if(!(a&5))
return 0;
/*for loop to check for prime numbers*/
for (int i=3,i<a&&<100,i+2=i)
isPrime=a%i
if (isPrime==0)
return 0;
}
return 1;
}
int primecombo(int a)
{
int i=1,beforecheck,firstprime,secondprime;
a=2;
for(i=1,i<=100,i++)
{
if(isPrime(a)==1)
firstprime=a;
else if(isPrime(a+i)==1)